[postgis-devel] Optimizing contains/within

Robert W. Burgholzer rburghol at vt.edu
Fri Jul 27 09:35:44 PDT 2007

Perhaps your objection could be satisfied by the function contains(geometry,
geometry[]), which would then only have to return the single result for each
containing geometry.

I am not saying that the already implemented solution is not better, but the
array option would not require the index.


Quoting Chris Hodgson <chodgson at refractions.net>:

> Robert W. Burgholzer wrote:
>  > Chris/others,
>  > Can't you simply use function overloading, such as the following
> (don't know if
>  > geometry[] is really the proper way to indicate and array of geometries):
>  >
>  > CREATE FUNCTION contains(geometry[],geometry[])
>  >    RETURNS boolean
>  >    AS 'C:/Program Files/PostgreSQL/8.2/lib/liblwgeom.dll'
>  >    LANGUAGE 'C' IMMUTABLE STRICT; -- WITH (isstrict,iscachable);
>  >
>  > to avoid the confusion that would arise from having to create a separate
>  > function like "points_in_polys"?
>  >
>  > r.b.
> I suppose you could, but that doesn't solve the problem of dealing with
> the 2d array of results that the function would have to return. Ie. for
> every pair of geometries in the inputs, does the left contain the right?
> Thats a lot of answers out of one function, and you can't use it in a
> "normal" query to get other columns of information included in the
> result. All in all it isn't really a realistic option, but is the only
> alternative I could think of to the somewhat more complicated (and
> apparently already implemented) second solution I mentioned.
> Chris
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel

Robert W. Burgholzer
Finding the occasional straw of truth awash in a great ocean of confusion and
bamboozle requires intelligence, vigilance, dedication and courage.  But if we
don't practice these tough habits of thought, we cannot hope to solve the truly
serious problems that face us -- and we risk becoming a nation of suckers, up
for grabs by the next charlatan who comes along.
-- Carl Sagan, "The Fine Art of Baloney Detection," Parade, February 1, 1987

Online Workout Editor:

More information about the postgis-devel mailing list