Jim Finnerty <jfinn...@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