Skip to content

Commit c7111d1

Browse files
Revert buggy optimization of index scans
606c012 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.
1 parent 6c90996 commit c7111d1

File tree

3 files changed

+0
-35
lines changed

3 files changed

+0
-35
lines changed

src/backend/access/nbtree/nbtsearch.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,33 +1026,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
10261026
if (goback)
10271027
offnum = OffsetNumberPrev(offnum);
10281028

1029-
/*
1030-
* By here the scan position is now set for the first key. If all further
1031-
* tuples are expected to match we set the SK_BT_MATCHED flag to avoid
1032-
* re-checking the scan key later. This is a big win for slow key matches
1033-
* though is still significant even for fast datatypes.
1034-
*/
1035-
switch (startKeys[0]->sk_strategy)
1036-
{
1037-
case BTEqualStrategyNumber:
1038-
break;
1039-
1040-
case BTGreaterEqualStrategyNumber:
1041-
case BTGreaterStrategyNumber:
1042-
if (ScanDirectionIsForward(dir))
1043-
startKeys[0]->sk_flags |= SK_BT_MATCHED;
1044-
break;
1045-
1046-
case BTLessEqualStrategyNumber:
1047-
case BTLessStrategyNumber:
1048-
if (ScanDirectionIsBackward(dir))
1049-
startKeys[0]->sk_flags |= SK_BT_MATCHED;
1050-
break;
1051-
1052-
default:
1053-
break;
1054-
}
1055-
10561029
/* remember which buffer we have pinned, if any */
10571030
Assert(!BTScanPosIsValid(so->currPos));
10581031
so->currPos.buf = buf;

src/backend/access/nbtree/nbtutils.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1429,13 +1429,6 @@ _bt_checkkeys(IndexScanDesc scan,
14291429
bool isNull;
14301430
Datum test;
14311431

1432-
/*
1433-
* If the scan key has already matched we can skip this key, as long
1434-
* as the index tuple does not contain NULL values.
1435-
*/
1436-
if (key->sk_flags & SK_BT_MATCHED && !IndexTupleHasNulls(tuple))
1437-
continue;
1438-
14391432
/* row-comparison keys need special processing */
14401433
if (key->sk_flags & SK_ROW_HEADER)
14411434
{

src/include/access/nbtree.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,6 @@ typedef BTScanOpaqueData *BTScanOpaque;
646646
*/
647647
#define SK_BT_REQFWD 0x00010000 /* required to continue forward scan */
648648
#define SK_BT_REQBKWD 0x00020000 /* required to continue backward scan */
649-
#define SK_BT_MATCHED 0x00040000 /* required to skip further key match */
650649
#define SK_BT_INDOPTION_SHIFT 24 /* must clear the above bits */
651650
#define SK_BT_DESC (INDOPTION_DESC << SK_BT_INDOPTION_SHIFT)
652651
#define SK_BT_NULLS_FIRST (INDOPTION_NULLS_FIRST << SK_BT_INDOPTION_SHIFT)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy