[postgis-devel] is this a bug, and other thoughts
nicklas.aven at jordogskog.no
nicklas.aven at jordogskog.no
Tue Jul 21 03:21:04 PDT 2009
Hallo
I have been investivating the st_dwithin-function. I have had a feeling that it is not bahaving consequently, and I think I have found en example proving something is wrong.
The problem is about the bounding-box comparasion. I tdon't think it always is doing things in the right order. Sometimes it does the _st_dwithin before comparing boundingboxes.
At my upset this is always doing it the wrong way. On the dataset Regina has attached to ticket #137 states.backup
if I do:
select a.state, b.state
from (select * from us.states where state != 'Hawaii')
a cross join
(select * from us.states where state = 'Hawaii') b
where a.the_geom && b.the_geom
I do get a fast answer that there is no match
but if I use st_dwithin like:
select a.state, b.state
from (select * from us.states where state != 'Hawaii')
a cross join
(select * from us.states where state = 'Hawaii') b
where st_dwithin(a.the_geom, b.the_geom,0)
it seems to start doing _st_dwithin(a.the_geom, b.the_geom,0) before doing the box-comparasion so I have never waited this out since _st_dwithin will have quite a har time with this dataset.
I find the same behavior in 1.3.6 with postgresql 8.3 as in postgis 1.4 with postgresql 8.4
I have a feeling that this is happening in som occasions because I sometimes get strange run-times. I think it sometimes do it right at some rows and the wrong way at somerows in big datasets, but that is much harder to prove.
another thought:
if I run as above
select a.state, b.state
from (select * from us.states where state != 'Hawaii')
a cross join
(select * from us.states where state = 'Hawaii') b
where a.the_geom && b.the_geom
it takes about 47ms to get the answer
but if I do the same with Alaska instead of Hawaii it takes over 300ms. Alaska is a very much more complex multipolygon but I don't understand why that is afecting when we just ask it to compare the bounding-boxes. Isn't the bboxes already stored with the geometry especially since a have an index on the_geom.
Or is there a boundingbox for each subgeom??, in that case I will use that in the distance-calculations, but I read somewhere that there is room for bbox onsubgeoms but they are not used. Is that the case but it is iterating through them anyway.
/Nicklas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-devel/attachments/20090721/216558ed/attachment.html>
More information about the postgis-devel
mailing list