[PostGIS] #6145: ST_AsMVTGeom: skip wagyu for polygons that stay simple in the tile
PostGIS
trac at osgeo.org
Sat Oct 10 07:32:01 PDT 2026
#6145: ST_AsMVTGeom: skip wagyu for polygons that stay simple in the tile
-----------------------------+---------------------------
Reporter: johncarmack1984 | Owner: pramsey
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS 3.8.0
Component: postgis | Version: 3.6.x
Keywords: mvt |
-----------------------------+---------------------------
ST_AsMVTGeom sends every polygon through wagyu
(`lwgeom_wagyu_clip_by_box`, from `mvt_clip_and_validate`), even one that
sits inside the tile and is still valid after the snap to the tile grid.
On Berlin's buildings at z14 tile 8802/5371 (2,128 polygons), wagyu was
68% of the database's CPU in a perf profile of PostGIS 3.6.4.
For a single ring inside the clip box that's simple after the snap, and
whose edges stay at least half a pixel from every vertex they don't end
at, wagyu returns the same ring: positive area in tile coordinates,
collinear vertices removed, starting where its sweep closes the ring. I
have a patch that finds those rings with exact integer tests and writes
them the way wagyu would. Everything else still goes to wagyu, and the
output is identical byte for byte.
Tiles per second, Berlin buildings, Martin 2.0's tile query, pgbench with
8 clients on 6 CPUs, master 83e5285:
||= Tiles =||= master =||= patch =||= =||
|| z14 8802/5371 || 492 || 1,200 || 2.45x ||
|| random z14 tiles || 1,310 || 3,194 || 2.44x ||
|| random z16 tiles || 11,794 || 19,367 || 1.65x ||
|| random z18 tiles || 37,650 || 42,515 || 1.12x ||
Compared against wagyu, 40,276,961 rings that took the fast path came out
identical: Berlin data at several zooms, extents and buffers, 2M random
rings, and an exhaustive enumeration of small rings on small grids. All
94,380 Berlin tiles I built at z8-z18 have the same md5 with and without
it.
This is for 3.8. Pull request to follow.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/6145>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.
More information about the postgis-tickets
mailing list