Re: Use zero for nullness estimates of system attributes - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Use zero for nullness estimates of system attributes
Date
Msg-id 23976.1548517484@sss.pgh.pa.us
Whole thread Raw
In response to Re: Use zero for nullness estimates of system attributes  (Jim Finnerty <jfinnert@amazon.com>)
List pgsql-hackers
Jim Finnerty <jfinnert@amazon.com> writes:
> It's related, but what I was referring to applies even to the uncorrelated
> case: suppose you have something like:

> select x, sum(z) 
> from t
> where
>     x > 5 and y in ('a', 'b', 'c')
> group by x;

> let's say that 'a', 'b', and 'c' are not frequent values of y, so the
> estimated selectivity is based on the n_distinct of y and the 3 values.  Now
> imagine that x > 5 is applied first.  That reduces the number of qualifying
> rows by the selectivity of (x > 5), but it may also reduce the number of
> distinct values of y.  If it reduces the n_distinct of y, then the IN
> predicate selectivity should be adjusted also.

I don't actually think that's a foregone conclusion.  If the two where
clauses are in fact independent, then simply multiplying their
selectivities together is the right thing.

            regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance
Next
From: Tom Lane
Date:
Subject: Opossum vs. float4 NaN