David Rowley <dgrowleyml@gmail.com> writes:
> It would be good to understand why get_parameterized_baserel_size()
> bothers accounting for the baserestrictinfo quals and does not just do
> clauselist_selectivity() on param_clauses alone and multiply by
> rel->rows (which should already account for the baserestrictinfo).
One reason is that clauselist_selectivity does not necessarily
treat all the clauses independently. For example, if "x > 1"
is in one list and "x < 4" is in the other, you'll get very
different (and worse) results if you keep the lists separate
and just multiply their selectivities together.
We do have per-RestrictInfo selectivity caching that eliminates
most of the apparent inefficiency in this.
regards, tom lane