[geos-devel] Fast collect() aggregate
    strk 
    strk at keybit.net
       
    Tue Oct 28 11:59:48 EST 2003
    
    
  
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;
    
    
More information about the geos-devel
mailing list