<p dir="auto">When osm2pgsql runs in append mode it deletes all objects for which it gets new versions from the middle tables before then adding the new version. For a typical diff many of these deletes will be unnecessary because the objects are new. With this commit the behaviour changes slightly: We first get the maximum id from the nodes/ways/relations middle tables. This operation is fast, because the PostgreSQL max() function is aware of the btree index on those tables. Later, before we delete an object we check the id against that maximum id, if it is larger the object can't be in the table and we don't do the delete.</p>
<p dir="auto">(Note that in theory we could use the fact that an object has version number 1 to figure out that it must be new. But this is much less robust than what we are doing here, for instance when the diff overlaps with the original import.)</p>
<p dir="auto">Performance improvement for small (minutely) diffs is not measurable, for large diffs about 10%.</p>
<hr>
<h4>You can view, comment on, or merge this pull request online at:</h4>
<p> <a href='https://github.com/openstreetmap/osm2pgsql/pull/2006'>https://github.com/openstreetmap/osm2pgsql/pull/2006</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/osm2pgsql/pull/2006/commits/d276b6e1c5d4ed3399abf68fdf2cf3fcf037f63e" class="commit-link">d276b6e</a> Append mode: Do not try to delete objects that can't exist in middle</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/osm2pgsql/pull/2006/files">2 files</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/osm2pgsql/pull/2006/files#diff-6237ae72dac71b4b88a541860afdb44f23a47ae252f8236a4522eacd2d6a766f">src/middle-pgsql.cpp</a>
(37)
</li>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/osm2pgsql/pull/2006/files#diff-658c580d094c7d459c656034c1ad794752b5dbe1e440df0fc026e5396743fd78">src/middle-pgsql.hpp</a>
(7)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/osm2pgsql/pull/2006.patch'>https://github.com/openstreetmap/osm2pgsql/pull/2006.patch</a></li>
<li><a href='https://github.com/openstreetmap/osm2pgsql/pull/2006.diff'>https://github.com/openstreetmap/osm2pgsql/pull/2006.diff</a></li>
</ul>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/osm2pgsql/pull/2006">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353V4UBOMV4G7DJJ2EJTXQTX3RANCNFSM6AAAAAA2MSPBKI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AA6353SERDA4CKO5ZZWROKLXQTX3RA5CNFSM6AAAAAA2MSPBKKWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHGXOBXLI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/osm2pgsql/pull/2006</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/osm2pgsql/pull/2006",
"url": "https://github.com/openstreetmap/osm2pgsql/pull/2006",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>