pgsql: Tweak index costing for problems with partial indexes.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Tweak index costing for problems with partial indexes.
Дата
Msg-id E1RreKa-0000Q2-5u@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Tweak index costing for problems with partial indexes.

btcostestimate() makes an estimate of the number of index tuples that will
be visited based on knowledge of which index clauses can actually bound the
scan within nbtree.  However, it forgot to account for partial indexes in
this calculation, with the result that the cost of the index scan could be
significantly overestimated for a partial index.  Fix that by merging the
predicate with the abbreviated indexclause list, in the same way as we do
with the full list to estimate how many heap tuples will be visited.

Also, slightly increase the "fudge factor" that's meant to give preference
to smaller indexes over larger ones.  While this is applied to all indexes,
it's most important for partial indexes since it can be the only factor
that makes a partial index look cheaper than a similar full index.
Experimentation shows that the existing value is so small as to easily get
swamped by noise such as page-boundary-roundoff behavior.  I'm tempted to
kick it up more than this, but will refrain for now.

Per report from Ruben Blanco.  These are long-standing issues, but given
the lack of prior complaints I'm not going to risk changing planner
behavior in back branches by back-patching.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/21a39de5809cd3050a37d2554323cc1d0cbeed9d

Modified Files
--------------
src/backend/utils/adt/selfuncs.c |   97 ++++++++++++++++++++++---------------
1 files changed, 58 insertions(+), 39 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix pushing of index-expression qualifications through UNION ALL
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix typo in comment.