Re: proposal : cross-column stats

Florian G. Pflug <fgp@phlo.org>

From: Florian Pflug <fgp@phlo.org>
To: Tomas Vondra <tv@fuzzy.cz>
Cc: pgsql-hackers@postgresql.org
Date: 2010-12-18T06:27:08Z
Lists: pgsql-hackers
On Dec17, 2010, at 23:12 , Tomas Vondra wrote:
> Well, not really - I haven't done any experiments with it. For two
> columns selectivity equation is
> 
>      (dist(A) * sel(A) + dist(B) * sel(B)) / (2 * dist(A,B))
> 
> where A and B are columns, dist(X) is number of distinct values in
> column X and sel(X) is selectivity of column X.

Huh? This is the selectivity estimate for "A = x AND B = y"? Surely,
if A and B are independent, the formula must reduce to sel(A) * sel(B),
and I cannot see how that'd work with the formula above.

best regards,
Florian Pflug