AW: [postgis-users] Overlaps query

Thorsten Kraus Thorsten.Kraus at ptv.de
Fri May 25 01:01:10 PDT 2007


Thanks for your answer. I have tried this before.

SELECT COUNT(a.id) FROM tbl1 a, tbl1 b WHERE a.geom && b.geom and a.id <>
b.id

But the result differs from my other query. Regarding to the PostGIS doc at
http://postgis.refractions.net/docs/ch06.html the && operator does not check
the spatial overlap of two geometries, it checks if the bounding boxes of
thw geometries overlap. But in my case I need to check if two geometries
spatially overlap. Perhaps there is a possibility to make this faster in
some way.

Regards, Thorsten

-----Ursprüngliche Nachricht-----
Von: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net]
Gesendet: Freitag, 25. Mai 2007 09:55
An: PostGIS Users Discussion
Betreff: Re: [postgis-users] Overlaps query




postgis-users-bounces at postgis.refractions.net wrote on 25/05/2007 09.41.05:

> Hi,
> I want to query a geometry column using the PostGIS function
> 'overlaps'. The query shoult return the number of overlapping
> geometries in a table.
> Here is the query I tried:
> SELECT COUNT(a.id) FROM tbl1 a, tbl1 b WHERE OVERLAPS(a.geom, b.
> geom) AND a.id <> b.id
> When I run the query, it takes a long time (96528ms) until PostGIS
> returns the result although my table only contains 10 rows. Is there
> a possibility to increase the performance of this query?
> Regards,
> Thorsten

Hi! I think you should use the && operator (a.the_geom && b.the_geom)
instead of the overlaps function (it doesn't use the GIST index, don't know
why) . I had the same problem, and the query went faster!

Bye,
Flavio

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070525/190cd273/attachment.html>


More information about the postgis-users mailing list