Skip to content

Commit 8e850b9

Browse files
committed
Advance multiple array keys rightmost-first instead of leftmost-first
during a bitmap index scan. This cannot affect the query results (since we're just dumping the TIDs into a bitmap) but it might offer some advantage in locality of access to the index. Per Greg Stark.
1 parent a2f1827 commit 8e850b9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/executor/nodeIndexscan.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.125 2008/01/01 19:45:49 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.126 2008/03/18 03:54:52 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -352,7 +352,13 @@ ExecIndexAdvanceArrayKeys(IndexArrayKeyInfo *arrayKeys, int numArrayKeys)
352352
bool found = false;
353353
int j;
354354

355-
for (j = 0; j < numArrayKeys; j++)
355+
/*
356+
* Note we advance the rightmost array key most quickly, since it will
357+
* correspond to the lowest-order index column among the available
358+
* qualifications. This is hypothesized to result in better locality
359+
* of access in the index.
360+
*/
361+
for (j = numArrayKeys - 1; j >= 0; j--)
356362
{
357363
ScanKey scan_key = arrayKeys[j].scan_key;
358364
int next_elem = arrayKeys[j].next_elem;

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