Ticket #547 (closed defect: fixed)
ST_contains memory problem when used between polygon and mixed geometry
| Reported by: | twain | Owned by: | strk |
|---|---|---|---|
| Priority: | blocker | Milestone: | PostGIS 2.0.0 |
| Component: | postgis | Version: | 1.5.X |
| Keywords: | ST_contains memory | Cc: |
Description
Tested with postgis 1.5.1:
The following query uses large amounts of memory (multiple GB depending on the number of rows)
select ST_Contains(source.geometry, placex.geometry) from placex, placex as source where source.place_id = 59001169 and source.geometry && placex.geometry;
where source.geometry is a polygon or multipolygon.
if the query is restricted to:
select ST_Contains(source.geometry, placex.geometry) from placex, placex as source where source.place_id = 59001169 and source.geometry && placex.geometry and ST_geometrytype(placex.geometry) = 'ST_Point';
OR
select ST_Contains(source.geometry, placex.geometry) from placex, placex as source where source.place_id = 59001169 and source.geometry && placex.geometry and ST_geometrytype(placex.geometry) != 'ST_Point';
neither of these queries has high memory usage.
In the original case all memory is freed when the query completed but given a large number of rows (10000+) it can use up all the memory in the machine causing it to swap and eventually kill the process.
As far as I can tell there is nothing special about the source polygons / multi polygon - any polygon shows this behaviour.

