[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgis-users
Subject:    [postgis-users] Fast collect() aggregate
From:       strk <strk () keybit ! net>
Date:       2003-10-28 16:59:48
Message-ID: 20031028175948.A59854 () freek ! keybit ! net
[Download RAW message or body]

I've made the fast collect() aggregate.
It uses geom_accum() as state transaction function
and a newly made collect_garray() as final function.

Running time to collect  8109 objects in 8102 geometries
goes from 32 minutes to less then 5 minutes.

I strongly belive no much more memory is used by new implementation
since array-accumulated geometries will be (in this case) bigger
then result collection by 8102 geometry headers (number of geoms in input).

Memory usage evaluation - though - is not easy with postgresql.

Anyway: here is how to enable 'fastcollect':

If you did not already do it for 'fastunion' create the geom_accum() function:

        CREATE FUNCTION geom_accum (geometry[],geometry)
                RETURNS geometry[]
                AS '$libdir/../libpostgis.so.0.8'
                LANGUAGE 'C';

Create the new collect_garray function and the aggregate:

        CREATE FUNCTION collect_garray (geometry[])
                RETURNS geometry
                AS '$libdir/../libpostgis.so.0.8'
                LANGUAGE 'C';

        CREATE AGGREGATE fastcollect (
                sfunc = geom_accum,
                basetype = geometry,
                stype = geometry[],
                finalfunc = collect_garray
        );
                                                        [

PS: remember to get in sync with CVS.

--strk;

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic