[postgis-users] ST_Within with subquery as parameter makes query slow
sfkeller at gmail.com
Tue Apr 18 16:01:12 PDT 2017
Recently I wrote this simple query:
SELECT count (*)
osm_point AS osm
(SELECT way FROM osm_polygon WHERE osm_id=-51701)
AND tags @> 'railway=>station';
This was slow (>30 sec.) I then moved the subquery out of ST_Within to
the FROM-clause like this:
osm_point AS osm,
(SELECT way FROM osm_polygon WHERE osm_id=-51701) AS ch
AND tags @> 'railway=>station'
This was faster (5 sec.). As it seems, the presence of the subquery is
blocking the inlining of ST_Within. Strange that the call overhead is
Is this effect only bound to ST_Within?
Does anyone know more about this?
More information about the postgis-users