I have a table with a column "multip" type GEOMETRY which contains a multipolygon. Each multipolygon contains several polygons. My table is very large (12 millions records).
I need a fast query on my table which extracts all lines of my table which has polygons which are in a map visible frame (latmin, latmax, lngmin, lngmax).
I currently use the ST_Dwithin operator with the following query:
SELECT id, mydata FROM mytable WHERE ST_Dwithin(multip, ST_TRANSFORM(ST_MakeEnvelope(" + myframe.join(',') + ", 4326), 2154),0) LIMIT 100
but this request is too slow.
Is there a way to speed up the query using a simplified version of the multipolygon ? For example by building a new column with polygon centroids instead?
Thanks for your suggestions!