[postgis-devel] Float vs Double Box

Mark Cave-Ayland mark.cave-ayland at siriusit.co.uk
Thu Nov 10 08:05:03 PST 2011


On 09/11/11 20:09, Nicklas Avén wrote:

> Another aspect of double vs float is that the float boxes might give
> wrong ordering from knn-gist.
>
> In other cases we can round the float box up to a slightly bigger box,
> but in the ordering case that will not help.
>
> That is why we get different answer from native Postgresql knn and
> PostGIS as I discussed the other week, because Postgresql is not using
> the bbox but the point itself. I'm I right or have I misunderstood?

Yes indeed, this was the reason I was suggesting that we should be using 
doubles for everything - coordinates, internal BBOXes and the index. 
Otherwise we find ourselves in situations where queries can return 
different results depending upon whether either a sequential scan or an 
index scan is used, or whether the geometry has an internal BBOX or not :(

Now obviously there is a penalty here in terms of index space but what 
we need to ask ourselves is what do we consider to be important? A query 
that takes less disk I/O but can semi-randomly return an incorrect 
answer, or a query that takes more disk I/O but consistently returns the 
correct answer? Perhaps in the past this wasn't so important, but now we 
are looking at using indices to accelerate more queries (such as 
KNN-GiST) it's going to become more of an issue moving forward.


ATB,

Mark.

-- 
Mark Cave-Ayland - Senior Technical Architect
PostgreSQL - PostGIS
Sirius Corporation plc - control through freedom
http://www.siriusit.co.uk
t: +44 870 608 0063

Sirius Labs: http://www.siriusit.co.uk/labs



More information about the postgis-devel mailing list