[Tile-serving] [openstreetmap/osm2pgsql] Append mode: Do not try to delete objects that can't exist in middle (PR #2006)

Jochen Topf notifications at github.com
Mon Jul 17 08:13:44 UTC 2023


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.

(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.)

Performance improvement for small (minutely) diffs is not measurable, for large diffs about 10%.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/osm2pgsql/pull/2006

-- Commit Summary --

  * Append mode: Do not try to delete objects that can't exist in middle

-- File Changes --

    M src/middle-pgsql.cpp (37)
    M src/middle-pgsql.hpp (7)

-- Patch Links --

https://github.com/openstreetmap/osm2pgsql/pull/2006.patch
https://github.com/openstreetmap/osm2pgsql/pull/2006.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/pull/2006
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/osm2pgsql/pull/2006 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20230717/23eb6983/attachment.htm>


More information about the Tile-serving mailing list