aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Riggs <simon@2ndQuadrant.com>2016-03-03 09:50:38 +0000
committerSimon Riggs <simon@2ndQuadrant.com>2016-03-03 09:50:38 +0000
commitbf7ced5e2dc8622f88129437a9adafc0bdd83041 (patch)
treeba6882b060c12d3fd3f428792bcd1553e714070d /src
parentf8a75881f90f88f4dc54f3692e4e1691cf2c0a91 (diff)
downloadpostgresql-bf7ced5e2dc8622f88129437a9adafc0bdd83041.tar.gz
postgresql-bf7ced5e2dc8622f88129437a9adafc0bdd83041.zip
Revert buggy optimization of index scans
606c0123d627 attempted to reduce cost of index scans using > and < strategies, though got that completely wrong in a few complex cases. Revert whole patch until we find a safe optimization.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/nbtree/nbtsearch.c27
-rw-r--r--src/backend/access/nbtree/nbtutils.c7
-rw-r--r--src/include/access/nbtree.h1
3 files changed, 0 insertions, 35 deletions
diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c
index d69a0577a87..101a7d80a95 100644
--- a/src/backend/access/nbtree/nbtsearch.c
+++ b/src/backend/access/nbtree/nbtsearch.c
@@ -1026,33 +1026,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
if (goback)
offnum = OffsetNumberPrev(offnum);
- /*
- * By here the scan position is now set for the first key. If all further
- * tuples are expected to match we set the SK_BT_MATCHED flag to avoid
- * re-checking the scan key later. This is a big win for slow key matches
- * though is still significant even for fast datatypes.
- */
- switch (startKeys[0]->sk_strategy)
- {
- case BTEqualStrategyNumber:
- break;
-
- case BTGreaterEqualStrategyNumber:
- case BTGreaterStrategyNumber:
- if (ScanDirectionIsForward(dir))
- startKeys[0]->sk_flags |= SK_BT_MATCHED;
- break;
-
- case BTLessEqualStrategyNumber:
- case BTLessStrategyNumber:
- if (ScanDirectionIsBackward(dir))
- startKeys[0]->sk_flags |= SK_BT_MATCHED;
- break;
-
- default:
- break;
- }
-
/* remember which buffer we have pinned, if any */
Assert(!BTScanPosIsValid(so->currPos));
so->currPos.buf = buf;
diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c
index 91331bad651..7857c77b220 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -1429,13 +1429,6 @@ _bt_checkkeys(IndexScanDesc scan,
bool isNull;
Datum test;
- /*
- * If the scan key has already matched we can skip this key, as long
- * as the index tuple does not contain NULL values.
- */
- if (key->sk_flags & SK_BT_MATCHED && !IndexTupleHasNulls(tuple))
- continue;
-
/* row-comparison keys need special processing */
if (key->sk_flags & SK_ROW_HEADER)
{
diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h
index 9e48efd8292..1b0c649c91d 100644
--- a/src/include/access/nbtree.h
+++ b/src/include/access/nbtree.h
@@ -644,7 +644,6 @@ typedef BTScanOpaqueData *BTScanOpaque;
*/
#define SK_BT_REQFWD 0x00010000 /* required to continue forward scan */
#define SK_BT_REQBKWD 0x00020000 /* required to continue backward scan */
-#define SK_BT_MATCHED 0x00040000 /* required to skip further key match */
#define SK_BT_INDOPTION_SHIFT 24 /* must clear the above bits */
#define SK_BT_DESC (INDOPTION_DESC << SK_BT_INDOPTION_SHIFT)
#define SK_BT_NULLS_FIRST (INDOPTION_NULLS_FIRST << SK_BT_INDOPTION_SHIFT)