[postgis-users] PostGIS spatial query performance

Dave Blasby dblasby at refractions.net
Fri Aug 9 09:46:02 PDT 2002


> > The base problem is that you are still asking the database to do something
> like:
> 
> >     For each feature in park
> >         see if there are any features in roads that are < 2km away
> 
> >  And thats going to take a long time.
> 
> Dave, is this really so? It thought it worked as a shortcut operator like &&
> in C:
> 
> for each feature in park
>         see if it overlaps with any feature in roads
>                 and only if so, compute the distance
> 
> As far as I know, lots of optimizing can be done within PostgreSQL by
> arranging selects, subselects and explicit joins. This would be especially
> important for the Java Topology Suite.

I was trying to be generic - but I think I ended up just being
ambiguous.

What I was trying to say was that the query (how every you do it -
either
with a sequence scan or an index scan) will always entail a lot of
work.  
You are always going to be comparing all the features in one table with
all the features in the other.  Using an index will make this comparison
very quick because it will instantly throw away most of the table.

dave




More information about the postgis-users mailing list