Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4c8ad67

Browse files
nbtree: Use only one notnullkey ScanKeyData.
_bt_first need only store one ScanKeyData struct on the stack for thepurposes of building an IS NOT NULL key based on an implied NOT NULLconstraint. We don't need INDEX_MAX_KEYS-many ScanKeyData structs.This saves us a little over 2KB in stack space. It's possible that thishas some performance benefit. It also seems simpler and more direct.It isn't possible for more than a single index attribute to need its ownimplied IS NOT NULL key: the first such attribute/IS NOT NULL key alwaysmakes _bt_first stop adding additional boundary keys to startKeys[].Using INDEX_MAX_KEYS-many ScanKeyData entries was (at best) misleading.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Mircea Cadariu <cadariu.mircea@gmail.com>Discussion:https://postgr.es/m/CAH2-Wzm=1kJMSZhhTLoM5BPbwQNWxUj-ynOEh=89ptDZAVgauw@mail.gmail.com
1 parent48c2c7b commit4c8ad67

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

‎src/backend/access/nbtree/nbtsearch.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,9 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
892892
OffsetNumberoffnum;
893893
BTScanInsertDatainskey;
894894
ScanKeystartKeys[INDEX_MAX_KEYS];
895-
ScanKeyDatanotnullkeys[INDEX_MAX_KEYS];
895+
ScanKeyDatanotnullkey;
896896
intkeysz=0;
897-
StrategyNumberstrat_total;
897+
StrategyNumberstrat_total=InvalidStrategy;
898898
BlockNumberblkno=InvalidBlockNumber,
899899
lastcurrblkno;
900900

@@ -1034,7 +1034,6 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
10341034
* need to be kept in sync.
10351035
*----------
10361036
*/
1037-
strat_total=BTEqualStrategyNumber;
10381037
if (so->numberOfKeys>0)
10391038
{
10401039
AttrNumbercurattr;
@@ -1122,16 +1121,15 @@ _bt_first(IndexScanDesc scan, ScanDirection dir)
11221121
ScanDirectionIsForward(dir) :
11231122
ScanDirectionIsBackward(dir)))
11241123
{
1125-
/*Yes, so build the key in notnullkeys[keysz] */
1126-
bkey=&notnullkeys[keysz];
1124+
/*Final startKeys[] entry will be deduced NOT NULL key */
1125+
bkey=&notnullkey;
11271126
ScanKeyEntryInitialize(bkey,
11281127
(SK_SEARCHNOTNULL |SK_ISNULL |
11291128
(impliesNN->sk_flags&
11301129
(SK_BT_DESC |SK_BT_NULLS_FIRST))),
11311130
curattr,
1132-
((impliesNN->sk_flags&SK_BT_NULLS_FIRST) ?
1133-
BTGreaterStrategyNumber :
1134-
BTLessStrategyNumber),
1131+
ScanDirectionIsForward(dir) ?
1132+
BTGreaterStrategyNumber :BTLessStrategyNumber,
11351133
InvalidOid,
11361134
InvalidOid,
11371135
InvalidOid,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp