I have a SELECT query which is taking way too long. The datasets are quite large, around 500MB. I only need to query data within a very specific and small bounding box (map tiles). My current statement seems to select all data from the whole dataset for each tile!
I would like to add perhaps a
ST_INTERSECTS in order to only select a very small part of the data, but not sure if this is the right approach?
I have a statement that looks like this. Part of it is generated through other software (Mapnik), so I can only control the
(SELECT * FROM file_wgdqwhafsbynudutfpdz) part of the statement.
SELECT ST_AsBinary("the_geom_3857") AS geom FROM (SELECT * FROM file_wgdqwhafsbynudutfpdz) as sub WHERE "the_geom_3857" && ST_SetSRID('BOX3D(270052.0209315277 3364987.296198315,270357.7690446685 3365293.044311455)'::box3d, 3857)
How can I make sure I only query the data that I need, ie. within the bounding box, by changing the
(SELECT * FROM file_wgdqwhafsbynudutfpdz) part of the statement?
(Also, what does the
BOX3D part of the statement actually do?