[postgis-devel] code reorganization in pgsql2shp.c

strk strk at keybit.net
Mon Nov 17 10:00:34 PST 2003


I don't really know about low-level handling of cursors by postgresql,
but I suppose the parse, rewrite, plan and optimize stages are skipped.

I don't think making a row buffer will speed up things very much.
If memory usage was a matter before, I think this is still the easiest
way to keep it low. If we want to buffer multiple rows we should also
compute their size to decide when to stop based on a threshold ....

If we care about speed, it might be worth using WKB or internal binary
representation instead of parsing WKT. Internal binary representation
will forget about endianness, so it will be safe only when both data
and dumper run on the same machine (or endian-compatible machines).

--strk;

pramsey wrote:
> It fetching one record at a time the best policy? Maybe a few hundred or 
> thousand at a time would be faster?
> 
> strk wrote:
> 
> > I've made a big re-organization of code in pgsql2shp.c
> > I hope this won't confuse anyone.
> > 
> > There is now a main loop fetching records from a cursor.
> > Each iteration will call a record handler function.
> > The very first iteration calls a shapefile initializer function.
> > 
> > The dumper runs slightly faster due to reduced string comparisions.
> > Records are fetched one by one, thus memory usage is greatly reduced.
> > Many bugs have been fixed and errors have been handled.
> > A lot of code has been cleaned up. I belive it is now more readable.
> > 
> > I did change creator functions signature to be the same for all type
> > of geometries thus allowing for an indirect call in the record handler
> > function. I did not look *inside* them. Their signature can probably
> > be reduced since most *global* variables have been moved to global scope.
> > They could also be faster using WKB, but that's probably not urgent.
> > 
> > Please give it a try.
> > 
> > --strk;
> > 
> > 
> > 
> > _______________________________________________
> > postgis-devel mailing list
> > postgis-devel at postgis.refractions.net
> > http://postgis.refractions.net/mailman/listinfo/postgis-devel
> 
> 
> -- 
>        __
>       /
>       | Paul Ramsey
>       | Refractions Research
>       | Email: pramsey at refractions.net
>       | Phone: (250) 885-0632
>       \_
> 
> 
> _______________________________________________
> postgis-devel mailing list
> postgis-devel at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-devel



More information about the postgis-devel mailing list