[postgis-users] Postgis Lean

David Blasby dblasby at refractions.net
Wed Dec 17 15:28:10 PST 2003

Ralph Mason wrote:
>   It would also shrink an index by some 
> as well.

No - the index size will be the same.  The index is actually based on a 
2D bounding box and link to the actual geometry.  The index size is 
directly proportial to the number of geometries being indexed, not on 
the size of the geometry.

Apart from that, you're right, you could save most of those bytes. 
Unfortunately, it would actually be a lot of work to change all the 
postgis functions to understand what you're doing.

As an easier alternative, you could create a new type based on WKB.
Internal storage would be like:

<xmin (double)>
<xmax (double)>
<ymin (double)>
<ymax (double)>
<SRID> (optional)

This is enough information to allow it to be indexed.  If you look at 
the postgis GiST indexing code, you'll see its fairly abstract - all you 
really need to do is convert your geometry into a BOX.  That information 
is at the top of my example geometry above.

Since postgis already has PostGIS->WKB and WKB->PostGIS, you can easily 
create a conversion function from postgis-> new geometry type and back. 
   You'll be able to do things like:

SELECT length(my_new_geometry_column) FROM table;

and postgresql will automatically convert your new geometry to a postgis 
geometry and returns its length.  This is slow, but you get all the 
postgis functionality for free.


More information about the postgis-users mailing list