Skip site navigation (1) Skip section navigation (2)

pgsql: Fix cost estimation for indexscan filter conditions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix cost estimation for indexscan filter conditions.
Date: 2012-04-12 00:25:37
Message-ID: (view raw or whole thread)
Lists: pgsql-committers
Fix cost estimation for indexscan filter conditions.

cost_index's method for estimating per-tuple costs of evaluating filter
conditions (a/k/a qpquals) was completely wrong in the presence of derived
indexable conditions, such as range conditions derived from a LIKE clause.
This was largely masked in common cases as a result of all simple operator
clauses having about the same costs, but it could show up in a big way when
dealing with functional indexes containing expensive functions, as seen for
example in bug #6579 from Istvan Endredy.  Rejigger the calculation to give
sane answers when the indexquals aren't a subset of the baserestrictinfo
list.  As a side benefit, we now do the calculation properly for cases
involving join clauses (ie, parameterized indexscans), which we always
overestimated before.

There are still cases where this is an oversimplification, such as clauses
that can be dropped because they are implied by a partial index's
predicate.  But we've never accounted for that in cost estimates before,
and I'm not convinced it's worth the cycles to try to do so.



Modified Files
src/backend/optimizer/path/costsize.c |   38 +++++++++++++++++---------------
1 files changed, 20 insertions(+), 18 deletions(-)

pgsql-committers by date

Next:From: Tom LaneDate: 2012-04-12 14:44:07
Subject: pgsql: Assorted spelling corrections.
Previous:From: Tom LaneDate: 2012-04-11 16:03:28
Subject: pgsql: Silently ignore any nonexistent schemas that are listed insearc

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group