[postgis-users] How to Delete Records Outside a Polygon?

Michael Fuhr mike at fuhr.org
Tue Sep 5 06:28:39 PDT 2006


On Tue, Sep 05, 2006 at 07:06:39AM -0600, Bill Thoen wrote:
> So when you perform the join by:
> JOIN counties AS c ON c.the_geom && f.the_geom
>     AND Intersects(c.the_geom, f.the_geom)
> 
> does the SQL optimizer really organize things so that it does all the
> comparisions by bounding boxes first before attempting the polygon
> intersection comparisions? Or do you have to write the '&&' comparision
> first to make this happen?

The query planner evaluates subexpressions in the order it thinks
best, which isn't necessarily the order given.  In this case, you
should get the same plan regardless of whether you write "a && b"
or "Intersects(a, b)" first.  You can use EXPLAIN or EXPLAIN ANALYZE
to confirm this.

-- 
Michael Fuhr



More information about the postgis-users mailing list