GiST index on data types that require compression - Mailing list pgsql-hackers

From Dave Blasby
Subject GiST index on data types that require compression
Date
Msg-id 3B0DBBA7.20FEC7C0@refractions.net
Whole thread Raw
Responses Re: GiST index on data types that require compression  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I'm trying to get my geometric type to spatially index.  I tried RTrees,
but they dont like objects that are bigger than 8k.

I'm now trying to get a GiST index to index based on the bounding box
thats contained inside the geometry.  So the index is on a GEOMETRY
type, but the index is only acting on the GEOMETRY->bvolume (which is a
BOX3D).

So far, it doesnt work.  Only one of my GiST support functions is called
(the compress function), after that I get the error message:
# create index qq on tp3 using gist (the_geom gist_geometry_ops) with
(islossy);
ERROR:  index_formtuple: data takes 8424504 bytes, max is 8191

I simplified the all the geometry in the test (tp3) table so they
contain only one point - each object is only a few hundred bytes, and
there's only 100 rows.

I'm obviously doing something very wrong.

My compress function looks like:

GISTENTRY *ggeometry_compress(GISTENTRY *entry)
{   BOX3D *tmp;   GISTENTRY *retval;
   if (entry->leafkey)    {    tmp = (BOX3D *) palloc(sizeof(BOX3D));    memcpy((char *) tmp, (char *) &(((GEOMETRY
*)(entry->pred))->bvol),
sizeof(BOX3D));
    retval = palloc(sizeof(GISTENTRY));    gistentryinit(*retval, (char *)tmp, entry->rel, entry->page,
   entry->offset, sizeof(BOX3D),FALSE);    return(retval);   }   else return(entry);
 
}


On its first (and only) call, the geometry ("entry->pred") really is the
first row in the tp3 table.

Does anyone have any ideas where to start tracking this problem down? 
Am I writing code for a very old version of GiST?

I've tried to find other examples of GiST using compression, but none of
them work.  "contrib/intarray" in the standard distribution just spins
(cpu 100%) when you try to build an index, and
"http://s2k-ftp.cs.berkeley.edu:8000/gist/pggist/" has an example using
the standard built-in polygon type (I based my code on it) - but its
really really old and I spent a few hours trying to get it to compile,
then gave up.


Any ideas or examples?

dave
ps. I'm using postgresql 7.1.1 with the gist.c 7.1 patch.  I get the
exact result with out-of-the-box-7.1.1.
pps. My code is available at
ftp://ftp.refractions.net/pub/refractions/postgis.c             ftp://ftp.refractions.net/pub/refractions/postgis.h
andthe sql definitions are at
 
ftp://ftp.refractions.net/pub/refractions/def.sql    and a dump of the tp3 table is at
ftp://ftp.refractions.net/pub/refractions/tp3.sql


pgsql-hackers by date:

Previous
From: "Christopher Kings-Lynne"
Date:
Subject: RE: Not released yet, but could someone take a quick peak ...
Next
From: Lincoln Yeoh
Date:
Subject: RE: Plans for solving the VACUUM problem