[postgis-devel] After ANALYZE, null_frac always 0

strk at refractions.net strk at refractions.net
Mon Oct 10 09:20:33 PDT 2005


On Thu, Oct 06, 2005 at 09:27:14PM -0600, Michael Fuhr wrote:
> After ANALYZE, pg_stats.null_frac shows 0 for geometry columns even
> if some values are NULL.  This appears to be due to the following
> line in compute_geometry_stats() (around line 2265 in lwgeom_estimate.c):
> 
>     stats->stanullfrac = null_cnt/samplerows;
> 
> null_cnt and samplerows are both integers, so integer division is
> done before the result is assigned to stanullfrac.  Shouldn't one
> of the operands be cast to float4 so stanullfrac gets the correct
> value?

Ehm.. yes, you're right.
I've added the cast to current CVS.
Thanks.

Anyway, consider that not all rows are scanned by
the estimator, just a sample ('samplerows'), so
you might continue to get 0 in stanullfrac after
patch application.

--strk;



More information about the postgis-devel mailing list