Stefan, This has to do with your data / configuration, not ST_Crosses, as the function clearly includes an index call.
CREATE OR REPLACE FUNCTION ST_Crosses(geometry,geometry) RETURNS boolean AS 'SELECT $1 && $2 AND _ST_Crosses($1,$2)' LANGUAGE 'SQL' IMMUTABLE; P. On Thu, Feb 16, 2012 at 3:51 PM, Stefan Keller <sfkel...@gmail.com> wrote: > Hi > > ST_Crosses doc says that it uses the spatial index (if available). > But I'm afraid it's not. I'm using PostGIS 1.5 on Linux. > > -- as it should be: > SELECT name > FROM osm_line a, osm_line b > WHERE a.osm_id != b.osm_id > AND ST_Crosses(a.way, b.way) > -- takes longer than 60 sec, 586 features. > > -- now with ST_Contains: > SELECT name > FROM osm_line a, osm_line b > WHERE ST_Contains('BOX(8.775 47.245, 8.873 47.208'::box2d,a.way) > AND ST_Contains('BOX(8.775 47.245, 8.873 47.208'::box2d,b.way) > AND a.osm_id != b.osm_id > AND ST_Crosses(a.way, b.way) > -- takes 3.5sec, 586 features. > > Obviously ST_Crosses does not consider the geometry index. > Why this? > > Yours, Stefan > _______________________________________________ > postgis-users mailing list > postgis-users@postgis.refractions.net > http://postgis.refractions.net/mailman/listinfo/postgis-users _______________________________________________ postgis-users mailing list postgis-users@postgis.refractions.net http://postgis.refractions.net/mailman/listinfo/postgis-users