[postgis-devel] GiST estimate and index_extent()

strk at refractions.net strk at refractions.net
Wed Jan 12 04:59:14 PST 2005


On Wed, Jan 12, 2005 at 11:31:46AM -0000, Mark Cave-Ayland wrote:
> Hi strk,
(cuts)
> I think I would envisage it as a separate function, something like
> column_extent(), since people would still need to use extent() for
> sub-selects, which will probably only make the code messier - it would also
> mean we could point out obvious mistakes where people are trying to use
> column_extent() in sub-selects and wondering why they are getting the wrong
> result ;)

I agree, but it needs a name avoiding clashes with other packages.
Could it be a generic GiST function ? 

> The other thing to consider would be to re-write the stats code so that PG80
> and < PG80 share the same code. As far as I can see, the only difference
> between the two versions should be where the data comes from - in the case
> of PG80 it is the pg_statistic table, whereas for PG < 80 it is the
> geometry_columns table. 
> 
> The ideal would be to take your (very good) statistical routines and
> abstract them so that they use a separate function to fetch/store the data
> for a column; the main routines would work using a pointer to an array of
> palloc'd floats. It would then only be the fetch/store routines that would
> be different, which would need to read/write the float arrays to either
> pg_statistic or geometry_columns depending upon the correct version. It
> should then be fairly trivial to get the estimated_extent() working for PG <
> 80, and would mean we could remove a lot of duplicate code from
> lwgeom_estimate.c. This definitely something worth doing before we hit RC
> stage IMHO.

mmm.. geometry_columns.stats is of type histogram2 (LWHISTOGRAM2d struct).
array of float is used as the GEOM_STATS structure.
Cleanest way would be make geometry_columns.stats a float[], 
but this would require a post-upgrade routine to fix the
table definition.

Incompatibilities between the two types are:

	o LWHISTOGRAM2D has boxesPerSide while GEOM_STATS
	  has separated cols and rows.

	o GEOM_STATS has avgFeatureCells, missing in LWHISTOGRAM2D

	o avgFeatureArea and extent coords are double for LWHISTOGRAM2D
	  and floats for GEOM_STATS.
	  has separated cols and rows.

--strk;



More information about the postgis-devel mailing list