[postgis-devel] Prepared Geometry API

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Tue Oct 7 13:29:34 PDT 2008


Obe, Regina wrote:
> Paul,
> 
> Something is bugging me about your choice of example.  Not that it is 
> important, but your a and b tables are the same constant so I would 
> expect a planner to realize that and make a and b point to the same 
> thing.  I'm not sure how that muddies your analysis. Also your constant 
> gets cast as a geometry only when it gets into ST_Contains and you are 
> doing a UNION instead of a UNION ALL.
> 
> What does the revised query give you
> 
> SELECT a.val as a, b.val as b, st_contains(a.val, b.val,0)
> FROM
>  (SELECT 'POINT(0 0)'::geometry as val UNION ALL SELECT 'POINT(1 
> 1)'::geometry as val) a,
>  (SELECT 'POINT(3 4)'::geometry as val UNION ALL SELECT 'POINT(1 
> 1)'::geometry as val) b;
> 
> Thanks,
> Regina

The UNION ALL seems to work for me. Using the attached patch against SVN 
trunk and EXPLAIN, it is possible to see that it is the Materialize node 
which causes the Datum pointers to change. Also it's worth noting that 
st_contains() invokes the bounding box filter first which is a little 
confusing when looking at this - things were a lot clearer to me using 
the following queries:


SELECT a.val as a, b.val as b, _st_containsprepared(a.val, b.val,0)
FROM
  (SELECT 'POINT(0 0)'::geometry as val UNION SELECT 'POINT(1 
1)'::geometry as val) a,
  (SELECT 'POINT(3 4)'::geometry as val UNION SELECT 'POINT(1 
1)'::geometry as val) b;


SELECT a.val as a, b.val as b, _st_containsprepared(a.val, b.val,0)
FROM
  (SELECT 'POINT(0 0)'::geometry as val UNION ALL SELECT 'POINT(1 
1)'::geometry as val) a,
  (SELECT 'POINT(3 4)'::geometry as val UNION ALL SELECT 'POINT(1 
1)'::geometry as val) b;


ATB,

Mark.

-- 
Mark Cave-Ayland
Sirius Corporation - The Open Source Experts
http://www.siriusit.co.uk
T: +44 870 608 0063
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arg_test.patch
Type: text/x-diff
Size: 1208 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20081007/1e9f6a46/attachment.patch>


More information about the postgis-devel mailing list