I am selecting a lot of polygons within a gigantic polygon by using the postgis function ST_Intersects().
SELECT
*
FROM
data.polygons AS poly,
data.gig_polygon AS gig
WHERE
ST_Intersects(poly.geom, gig.geom)
The gigantic polygon is just a (one row) large sized polygon at the moment. The query is taking a very long time. I was wondering if it would be faster to split the gigantic polygon in multiple smaller polygons and run the query again. I dont want to cancel it without knowing this will be faster. To know the answer to my question I guess you have to understand in what way the ST_Intersects() function works.
Does anybody know that? Or knows another way of speeding up the ST_Intersect() functionality?
ST_Intersects()
is slow when comparing polygons where one or more of them has a large number of vertices; I routinely checkST_Intersects()
between rectangular cadastre polygons (with 4 vertices) against zoning polygons (with sometimes upwards of 40,000 vertices per zoning polygon, and over a thousand polygons in the state). That's the nature of the comparison being performed, unfortunately.