[PostGIS] #5953: Slow st_intersection with big input polygons
PostGIS
trac at osgeo.org
Wed Jul 30 12:09:12 PDT 2025
#5953: Slow st_intersection with big input polygons
--------------------------------+---------------------------
Reporter: Lars Aksel Opsahl | Owner: pramsey
Type: enhancement | Status: new
Priority: medium | Milestone: PostGIS 3.6.0
Component: postgis | Version: master
Resolution: | Keywords:
--------------------------------+---------------------------
Comment (by mdavis):
My take on this is:
Running intersections against the subdivided polygon is faster than
against the whole polygon because there many subpolygons are eliminated
from processing (by the intersects filter), and the subpolygons are much
smaller than the original polygon.
The test against the polygon with holes removed isn't apples-to-apples,
since it runs `ST_BuildArea` and `ST_Boundary`. These might be taking
significant time. Materializing the boundary polygon in a separate table
would reveal if this is the cause of the slowdown.
Unlike `ST_Intersects`, `ST_Intersection` has no "prepared mode", so it
has to compute using the entire input on each call. Using `ST_Subdivide`
is a way around this. If all you need is the area of intersection,
developing a workflow using this technique could be the way to go.
--
Ticket URL: <https://trac.osgeo.org/postgis/ticket/5953#comment:2>
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