| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | Jim Finnerty <jfinnert(at)amazon(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: Use zero for nullness estimates of system attributes |
| Date: | 2019-01-26 15:44:44 |
| Message-ID: | 23976.1548517484@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Jim Finnerty <jfinnert(at)amazon(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2019-01-26 16:00:05 | Opossum vs. float4 NaN |
| Previous Message | Tom Lane | 2019-01-26 15:41:59 | Re: [Patch] Log10 and hyperbolic functions for SQL:2016 compliance |