<p dir="auto">This forces the DELETEs to use an index scan which is much faster.</p>
<p dir="auto">The underlying problem here is probably that the DELETEs are called for all OSM objects in the input file, regardless of whether they are even in the table. For most tables most ids will not be in there. So PostgreSQL overestimates the number of "hits" it is going to get and thinks a full table scan is more efficient when in fact an index lookup is much better.</p>
<p dir="auto">The COPYs used in the same database connection are not affected by this.</p>
<p dir="auto">In many tests I have done I only see this problem in some cases, but when it hits it can slow down processing considerably. This could explain the occasional slow processing that some people have been reporting over the years and that we could never really nail down (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1236207232" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/osm2pgsql/issues/1674" data-hovercard-type="issue" data-hovercard-url="/openstreetmap/osm2pgsql/issues/1674/hovercard" href="https://github.com/openstreetmap/osm2pgsql/issues/1674">#1674</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="5258383" data-permission-text="Title is private" data-url="https://github.com/openstreetmap/osm2pgsql/discussions/1971" data-hovercard-type="discussion" data-hovercard-url="/openstreetmap/osm2pgsql/discussions/1971/hovercard" href="https://github.com/openstreetmap/osm2pgsql/discussions/1971">#1971</a>).</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/1997'>https://github.com/openstreetmap/osm2pgsql/pull/1997</a></p>
<h4>Commit Summary</h4>
<ul>
<li><a href="https://github.com/openstreetmap/osm2pgsql/pull/1997/commits/9ce15e57fed9e0bb4e09540027fcd23d7649ed72" class="commit-link">9ce15e5</a> Disable sequential scan on database tables in copy threads</li>
</ul>
<h4 style="display: inline-block">File Changes </h4> <p style="display: inline-block">(<a href="https://github.com/openstreetmap/osm2pgsql/pull/1997/files">1 file</a>)</p>
<ul>
<li>
<strong>M</strong>
<a href="https://github.com/openstreetmap/osm2pgsql/pull/1997/files#diff-037c31cfecf376a564eabe2b2ced673d2d0173405b58ce85a83fdc51a4f348c3">src/db-copy.cpp</a>
(8)
</li>
</ul>
<h4>Patch Links:</h4>
<ul>
<li><a href='https://github.com/openstreetmap/osm2pgsql/pull/1997.patch'>https://github.com/openstreetmap/osm2pgsql/pull/1997.patch</a></li>
<li><a href='https://github.com/openstreetmap/osm2pgsql/pull/1997.diff'>https://github.com/openstreetmap/osm2pgsql/pull/1997.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/1997">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AA6353UJXHOUJHGMXKMDOM3XQEJU3ANCNFSM6AAAAAA2KDNAAM">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AA6353VXOX3W6HC2RW44MWDXQEJU3A5CNFSM6AAAAAA2KDNAAOWGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHGXD5ZPQ.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/1997</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/1997",
"url": "https://github.com/openstreetmap/osm2pgsql/pull/1997",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>