[postgis-devel] Re: geometry stats

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Thu Mar 4 02:51:55 PST 2004


Hi Dave,

> -----Original Message-----
> From: David Blasby [mailto:dblasby at refractions.net] 
> Sent: 01 March 2004 20:33
> To: Mark Cave-Ayland
> Cc: 'PostGIS Development Discussion'; strk
> Subject: Re: [postgis-devel] Re: geometry stats

(lots cut)

> So;
> 
> 1. There shouldnt be anything wrong with the && operator.  If 
> anyone's 
> ever seen an example of the index and seq scan returning different 
> results, SEND ME THE TEST.  I'm going to write a simple 
> program to test 
> the current one (as I outlined earlier today).
> 
> 2. We can fix the '@~'-like operators by either (a) adding RECHECK to 
> the definition or (b) adding the leaf consistent function (as in the 
> rtree_gist 7.4 implementation shown above) or (c) both.


Well done on finding out what was happening from the indexes :). I
hadn't really looked at the rtree_gist code in any detail, but I'd
failed to notice that the implementation requires different functions
for internal and leaf nodes.

As a result of this, I've been playing around with the index code and
have produced a modified version of postgis_gist_72.c based upon this
work. The main points about this patch are:


1) Implemented a solution based upon b) as you suggested above by
working against
   the PG 7.2 rtree_gist source and compiling/testing under PG 7.5 CVS.

2) Yesterday I tried lots of tests comparing the box_overlap() function
with strk's
   pg_boxoverlap but for me both tests always returned the same results.
strk,
   can you provide Dave with a case that fails as I can't replicate a
problem
   here? Since I can't find a problem in the code then I've reverted
back to the
   old box_overlap() code just to keep everything consistent...

3) Changed the rtree_*_consistent() functions to be defined as 'static'
as per the
   PG 7.2 rtree_gist.


I've tested this against Chris' original test case for the problem with
the @ and ~ operators
(http://postgis.refractions.net/pipermail/postgis-users/2003-March/00217
3.html) and these operators now work correctly with this patch.

I also think that there is a bug in the rtree_gist() implementation of
rtree_internal_consistent(). If you take a look at the RTOverRight and
RTRight strategies use box_right(), while the RTOverLeft and RTLeft
strategies use box_overleft().

Having thought about this, I believe that the RT*Right operators are
wrong, and they should be using box_overright(). The logic behind this
is that if you have an rtree internal node containing a point on the
right-hand edge of its bounding box, and your query box has a left-hand
edge equal to the right-hand of the internal rtree bounding box, then
you would still need to go down that path in the tree in order to return
the point on the right-hand edge of your node. The patch also
incorporates this fix.

As regarding the RECHECK operator, I would say that either all index
operators should have them or none should have them. I would argue that
the only reason they should be added is if people want a SRID mismatch
to throw an error, not to correct problems in the index implementation.
strk commented that this would take extra time, however because tuple
visibility is not stored in the index then the tuples would already be
in memory, and so I would be surprised if the impace were that great.
This is only a gut feeling at the moment as I haven't run any benchmarks
to test this - how do other people feel about this?


Cheers,

Mark.

---

Mark Cave-Ayland
Webbased Ltd.
Tamar Science Park
Derriford
Plymouth
PL6 8BX
England

Tel: +44 (0)1752 764445
Fax: +44 (0)1752 764446


This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender. You
should not copy it or use it for any purpose nor disclose or distribute
its contents to any other person.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postgis_gist_72.diff
Type: application/octet-stream
Size: 6637 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20040304/a90b1974/attachment.obj>


More information about the postgis-devel mailing list