pgsql: Tweak index costing for problems with partial indexes.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Tweak index costing for problems with partial indexes.
Date: 2012-01-29 23:38:44
Message-ID: E1RreKa-0000Q2-5u@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-01-29 23:57:07 pgsql: Fix typo in comment.
Previous Message Tom Lane 2012-01-29 21:32:07 pgsql: Fix pushing of index-expression qualifications through UNION ALL