[postgis-devel] Fwd: ST_DumpPoints in C

Nathan Wagner nw at hydaspes.if.org
Mon Oct 15 11:12:39 PDT 2012

On Mon, Oct 15, 2012 at 10:34:21AM -0700, Paul Ramsey wrote:
> FYI, there's a C implementation of dumppoints available for testing.
> If it's OK w/ y'all I'll pull it into trunk. Let me know.

Feedback welcome.  Testing as an extension uses pgtap.  It's about four
times faster in my testing to dump 1.2 million points into a temp table.
Getting the first few points (i.e. select st_dumppoints(...) limit 10)
is much faster.

I think it could be faster yet, but it would require more direct
knowledge of the lwgeom and gserialized implementation.  I think, but
have not profiled, that the memory allocation is the main cause of the
slowness.  I have tried to minimize that.

Some of the code I wrote could probably be used to speed up ST_Dump()
also, though that is probably not especially slow.

Someone a few years back posted a point dumper that used regexes to
match out of the text representation of a geometry.  That was remarkably
fast, but it didn't provide the path array, so I don't know how usable
it would be.  Obviously that uses a bunch of memory all at once.
However, we end up copying and allocating memory for the points and
sub-geometries anyway, so in practice, that might not be a problem.

So it might be faster to do all the work up front on the first call and
then just return them as needed.  Doing it this way would presumably be
slower to generate the first few points.  It might make sense to have an
ST_DumpPointsMem() interface or some such to that type of


More information about the postgis-devel mailing list