[postgis-users] relationship functions not working well

Martin Davis mbdavis at refractions.net
Fri Dec 5 10:44:54 PST 2008


Yep, relate doesn't automatically use the spatial index.  You could also 
use the && operator as a filter condition - that will avoid running 
intersects unecessarily.

William Kyngesburye wrote:
> On Dec 5, 2008, at 11:22 AM, Martin Davis wrote:
>
>> Good news!  I thought about this some more overnight, and I realized 
>> that the relation "interior-intersects" should produce the result 
>> you're looking for.  This still doesn't have a named predicate, but 
>> the really good news is that the IM pattern for this is trivial:  
>> [T********] .
>>
>> (Exercise left for the student: Prove that the pattern expression for 
>> "intersects-and-not-touches"  is equivalent to [T********].  Or not - 
>> the proof in either situation would be interesting)
>
>
> Well, that works:
>
> ST_relate(wkb_geometry, SetSRID('BOX3D(-162 55,-161 56)'::box3d,4326), 
> 'T********')
>
> But it's painfully slow - looks like relate doesn't do an index 
> bounding box test.
>
> ... added a normal intersect (it's a superset of what I want) and let 
> short-circuit logic take care of the initial selection:
>
> ST_Intersects(wkb_geometry, SetSRID('BOX3D(-162 55,-161 
> 56)'::box3d,4326)) AND ST_relate(wkb_geometry, SetSRID('BOX3D(-162 
> 55,-161 56)'::box3d,4326), 'T********')
>
> That's reasonably fast, for a small box at least.  It will likely slow 
> down on a larger box.
>
> -----
> William Kyngesburye <kyngchaos*at*kyngchaos*dot*com>
> http://www.kyngchaos.com/
>
> "Those people who most want to rule people are, ipso-facto, those 
> least suited to do it."
>
> - A rule of the universe, from the HitchHiker's Guide to the Galaxy
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>

-- 
Martin Davis
Senior Technical Architect
Refractions Research, Inc.
(250) 383-3022




More information about the postgis-users mailing list