[postgis-devel] Question about BoundingBoxes and optimization

Jorge Arévalo jorge.arevalo at deimos-space.com
Sat Oct 9 10:52:50 PDT 2010


Hello,

I want to make a range query: get all features that reside inside a
box2D. Then, in the ST_MakeBox2D manual page, I can see this example
query:

SELECT feature_id, feature_name, the_geom
FROM features
WHERE the_geom && ST_SetSRID(ST_MakeBox2D(ST_Point(-989502.1875, 528439.5625),
	ST_Point(-987121.375 ,529933.1875)),2163)

At same time, in section 4.7.1 of SVN manual
(http://postgis.refractions.net/documentation/manual-svn/ch04.html#id3058151),
there's a note that states:

"As of PostGIS 1.3.0, most of the Geometry Relationship Functions,
with the notable exceptions of ST_Disjoint and ST_Relate, include
implicit bounding box overlap operators."

So, if I'm using PostGIS >= 1.3.0, may I use this query instead of the
one above?

SELECT feature_id, feature_name, the_geom
FROM features
WHERE ST_Intersects(ST_SetSRID(ST_MakeBox2D(ST_Point(-989502.1875, 528439.5625),
	ST_Point(-987121.375 ,529933.1875)),2163), the_geom)

(BTW, I use ST_Intersects instead of ST_Overlaps because I want the
features completely contained inside the query box to be included in
the resultset too, but it's not important for my question, I think)

Many thanks in advance!

-- 
Jorge Arévalo
Internet & Mobilty Division, DEIMOS
jorge.arevalo at deimos-space.com
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com



More information about the postgis-devel mailing list