[postgis-devel] Re: geometry stats

Mark Cave-Ayland m.cave-ayland at webbased.co.uk
Wed Feb 25 05:14:50 PST 2004


Hi strk,

> > Looking at the comments in postgis_estimate.c, do you really get 
> > different query results when uncommenting your 'selectivity 
> = 0.9'? Is 
> > this true if you try different values, say from 0.1 to 0.9?
> 
> Yes, box_overlap() is not the same as geometry_overlap().
> There are no traces of box_overlap() in postgis code though,
> so the late broke might depends on external factors.

Yeah, box_overlap() is a routine from the internal PostgreSQL geometric
functions (see src/backend/utils/adt/geo_ops.c). The current way it
works is that a BOX3D is converted into a BOX and then box_overlap() is
called. Yuck. The fix in the thread I mentioned before was that I wrote
my own equivalent of the contains() operator and added it into PostGIS
instead of calling the PostgreSQL contains/contained functions which
just appeared to be plain broken.

So can you clarify again: are you seeing different results depending
upon whether a sequential scan/index scan is being used, or do you get
different results with the same query plan but returning a different
value for the selectivity?

> > I suppose the other possibility is that some memory is being 
> > overwritten where it shouldn't be. I've had another quick 
> look at your 
> > new code and the only thing I've noticed at first sight is that 
> > PostgreSQL passes float4 values by reference(!) and not by 
> value which 
> > may cause the
> > get_attstatlot()/free_attrstatslot() not to handle memory as they
> > should. Then again I would expect this to have been more 
> likely to seg
> > fault rather than upset the query....

Actually don't worry about this - it looks as if this is only the case
for stavalues and not stanumbers - so we should be safe.

> I actually get a random segfault, isn't this a 
> get_attstatslot bug, anyway ? 

This is in the estimation function, right? Can you narrow it down to a
particular area at all, i.e. if you just have the function do nothing
except call get_attstatslot(), free_attstatslot() and return the default
selectivity, does it still crash? I think this would be a good test.

> I guess I'll be waiting for you on this :)

I'll try and help out as much as I can in the meantime.


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.





More information about the postgis-devel mailing list