On 22 December 2017 at 12:45, Robert Haas <robertmhaas@gmail.com> wrote:
> PREPARE q3 (int, int) AS SELECT * FROM unpartitioned_table WHERE
> partkey BETWEEN $1 AND $2;
>
> ...that has to decide whether to use an index. And to do that it has
> to estimate what fraction of the table will match the BETWEEN clause.
> That may be an uninformed guess, but it guesses something. We
> probably want to do something here that makes the guess for a
> partitioned_table similar to the guess for an unpartitioned_table.
Are you considering some sort of clauselist_selectivity() estimate on
the given parameters and comparing that to the same selectivities that
were determined for the previous custom plans?
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services