[postgis-users] ST_equals not using index ?

Arnaud Lesauvage arnaud.listes at codata.eu
Fri Aug 13 05:15:45 PDT 2010


Hi list !

Using Postgis 1.4.1 on PostgreSQL 8.4.3 here (Win32).
I just realized that ST_Equals did not use the GIST index on the 
geometry column.
Is this normal ? What is the reason for this ?

I used it to check for duplicate geometries in a table, and whereas
SELECT * FROM mytable t1 WHERE EXISTS
	(SELECT 1 FROM mytable t2 WHERE t1.pkey != t2.pkey
	AND ST_Equals(t1.thegeom,t2.thegeom));
did not use the index on "thegeom",
SELECT * FROM mytable t1 WHERE EXISTS
	(SELECT 1 FROM mytable t2 WHERE t1.pkey != t2.pkey
	AND ST_Equals(t1.thegeom,t2.thegeom)
	AND t1.thegeom && t2.thegeom);
did.
I had to stop the first query after it ran for 1hour and "explain" it to 
realize this. The second query ran in 25s.

Thanks a lot !

Best regards,
Arnaud Lesauvage



More information about the postgis-users mailing list