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

pgsql: Fix gincostestimate to handle ScalarArrayOpExpr reasonably.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix gincostestimate to handle ScalarArrayOpExpr reasonably.
Date: 2011-12-21 00:57:55
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Fix gincostestimate to handle ScalarArrayOpExpr reasonably.

The original coding of this function overlooked the possibility that
it could be passed anything except simple OpExpr indexquals.  But
ScalarArrayOpExpr is possible too, and the code would probably crash
(and surely give ridiculous answers) in such a case.  Add logic to try
to estimate sanely for such cases.

In passing, fix the treatment of inner-indexscan cost estimation: it was
failing to scale up properly for multiple iterations of a nestloop.
(I think somebody might've thought that index_pages_fetched() is linear,
but of course it's not.)

Report, diagnosis, and preliminary patch by Marti Raudsepp; I refactored
it a bit and fixed the cost estimation.

Back-patch into 9.1 where the bogus code was introduced.



Modified Files
src/backend/utils/adt/selfuncs.c      |  496 +++++++++++++++++++++++----------
src/test/regress/expected/tsearch.out |   12 +
src/test/regress/sql/tsearch.sql      |    2 +
3 files changed, 366 insertions(+), 144 deletions(-)

pgsql-committers by date

Next:From: Robert HaasDate: 2011-12-21 13:54:11
Subject: pgsql: Shave a few cycles in string_agg().
Previous:From: Tom LaneDate: 2011-12-20 20:01:24
Subject: pgsql: Avoid crashing when we have problems unlinking filespost-commit

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