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

pgsql: Clamp indexscan filter condition cost estimate to be not lessth

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Clamp indexscan filter condition cost estimate to be not lessth
Date: 2012-04-12 00:25:37
Message-ID: E1SI7qz-0005qe-CY@gemulon.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-committers
Clamp indexscan filter condition cost estimate to be not less than zero.

cost_index tries to estimate the per-tuple costs of evaluating filter
conditions (a/k/a qpquals) by subtracting the estimated cost of the
indexqual conditions from that of the baserestrictinfo conditions.  This is
correct so long as the indexquals list is a subset of the baserestrictinfo
list.  However, in the presence of derived indexable conditions it's
completely wrong, leading to bogus or even negative scan cost estimates,
as seen for example in bug #6579 from Istvan Endredy.  In practice the
problem isn't severe except in the specific case of a LIKE optimization on
a functional index containing a very expensive function.

A proper fix for this might change cost estimates by more than people would
like for stable branches, so in the back branches let's just clamp the cost
difference to be not less than zero.  That will at least prevent completely
insane behavior, while not changing the results normally.

Branch
------
REL8_4_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/8d444c90d87115934874d07e61f1c080b282aa6e

Modified Files
--------------
src/backend/optimizer/path/costsize.c |   11 ++++++++++-
1 files changed, 10 insertions(+), 1 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-2014 The PostgreSQL Global Development Group