mysociety/mapit — Issue #16: Intersect call timeouts
Author: dracos
Created: 2011-12-31 16:40:58+00:00
State: open

Some queries on large geometries - e.g. 2217/touches (other geometries touching Buckinghamshire) - time out (the timeout is currently set to 10 seconds to prevent server overloading). The query for this call takes c. 20 seconds to run:

explain analyze
SELECT DISTINCT areas_area.*
FROM "areas_area" , "areas_geometry" WHERE (
areas_geometry.area_id = areas_area.id
AND areas_geometry.polygon && (select st_collect(polygon) from areas_geometry where area_id=2217)
AND ST_touches(areas_geometry.polygon, (select st_collect(polygon) from areas_geometry where area_id=2217))
AND NOT "areas_area"."id" = 2217
AND "areas_area"."generation_low_id" <= 15
AND "areas_area"."generation_high_id" >= 15
)
ORDER BY "areas_area"."name" ASC, "areas_area"."type" ASC ;

Can this be improved/fixed?