[postgis-users] performance of intersects(a,b)

Paul Ramsey pramsey at cleverelephant.ca
Mon Feb 18 16:54:08 PST 2008


Right, this:

  select 'yes' as foo
  from table1 a, table1 b
  where a.gid=4
  and b.gid=4
  and st_intersects(a.the_geom, b.the_geom)

seems likely to a LOT less common than

  select 'yes' as foo
  from table1 a, table1 b
  where a.gid=4
  and st_intersects(a.the_geom, b.the_geom)

and the latter gets far less benefit from the a.getpoint(0) =
b.getpoint(0) test, though the test would still be run on every
candidate.  I'm not sure where the cost/benefit inflection point is,
but I know identity is a pretty rare case.

P.

On 2/18/08, Martin Davis <mbdavis at refractions.net> wrote:
> There's some new code on the way in GEOS and PostGIS which will improve
> the performance of this case.  Bu it won't be anywhere near as fast as
> your proposed check for an identical start point.
>
> The "identical start point" check is great for the particular case of
> comparing identical polygons.  But it does nothing for the general
> case.  The question is:  is the identical compare case common enough
> that it's worth adding in this check for all cases?
>
> Willy-Bas Loos wrote:
> > Hi,
> >
> > I´ve noticed that intersect(a,b) is slow when i compare a (nice and
> > large) geometry with itself.
> > so the syntax is:
> >
> > select 'yes' as foo
> > from table1 a, table1 b
> > where a.gid=4
> > and b.gid=4
> > and intersects(a.the_geom, b.the_geom)
> >
> > This particular polygon has about 10 000 points, and the query runs
> > for 4 whole seconds.
> > At the first point that is being compared, however, PostGIS should
> > notice that it has a "positive".
> >
> > I´m only using postgis 1.0, so this migt have been changed allready.
> > Has it?
> >
> > WBL
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > postgis-users mailing list
> > postgis-users at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-users
> >
>
> --
> Martin Davis
> Senior Technical Architect
> Refractions Research, Inc.
> (250) 383-3022
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list