[Tile-serving] [openstreetmap/osm2pgsql] Middle: Get dependencies with single queries (PR #1996)

Jochen Topf notifications at github.com
Thu Jul 13 15:24:30 UTC 2023


In append mode osm2pgsql has to find all parent ways and relations of changed nodes and parent relations of changed ways. This is done by with one query per object read from the input file which is quite wasteful. This changes the code to only do a single query for all dependencies. The list of all changed ids is COPYied into a temporary table. Then parent objects ids are found and written into another temporary table and then retrieved. (We could this without the extra temporary tables, but this could allow us later to use the content of those tables somewhere else, so I chose to do it this way. Should make a big difference perfomance-wise.)

These PR also fixes #423, the longstanding problem that ways and relations that are in the input file AND parents of changed objects were process twice.

The work is split between three commits, one each for nodes, ways, and relations processing.

I did some performance measurements, in every one the new code was more efficient. For smaller (minutely) diffs the difference is small, about 30% performance improvements measured over 2000 something diffs. At the other end of the spectrum the performance gain is huge. Updating a planet file with a diff with about two weeks of data was an order of magnitude faster (from >10h down to an hour).
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * Find node dependencies faster by doing a single lookup
  * Find way dependencies faster by doing a single lookup
  * Make sure not to process relations twice in append mode

-- File Changes --

    M src/dependency-manager.cpp (80)
    M src/dependency-manager.hpp (45)
    M src/middle-pgsql.cpp (248)
    M src/middle-pgsql.hpp (13)
    M src/middle.hpp (16)
    M src/osmdata.cpp (22)
    M src/pgsql-helper.cpp (7)
    M src/pgsql-helper.hpp (3)
    M tests/test-middle.cpp (10)

-- Patch Links --

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

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

Message ID: <openstreetmap/osm2pgsql/pull/1996 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20230713/12898b39/attachment.htm>


More information about the Tile-serving mailing list