aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/nodeIndexscan.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-03-18 03:54:52 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-03-18 03:54:52 +0000
commit8e850b9159b1519dcc20982c39cfc3ff16d3d31b (patch)
tree406e8db8c63a4aea6448478923047cc07279cc67 /src/backend/executor/nodeIndexscan.c
parenta2f1827dfd21a670272d7c7ffe2d4902cfff990e (diff)
downloadpostgresql-8e850b9159b1519dcc20982c39cfc3ff16d3d31b.tar.gz
postgresql-8e850b9159b1519dcc20982c39cfc3ff16d3d31b.zip
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.
Diffstat (limited to 'src/backend/executor/nodeIndexscan.c')
-rw-r--r--src/backend/executor/nodeIndexscan.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 2db4015504e..59f54ee5cb4 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.125 2008/01/01 19:45:49 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/executor/nodeIndexscan.c,v 1.126 2008/03/18 03:54:52 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -352,7 +352,13 @@ ExecIndexAdvanceArrayKeys(IndexArrayKeyInfo *arrayKeys, int numArrayKeys)
bool found = false;
int j;
- for (j = 0; j < numArrayKeys; j++)
+ /*
+ * Note we advance the rightmost array key most quickly, since it will
+ * correspond to the lowest-order index column among the available
+ * qualifications. This is hypothesized to result in better locality
+ * of access in the index.
+ */
+ for (j = numArrayKeys - 1; j >= 0; j--)
{
ScanKey scan_key = arrayKeys[j].scan_key;
int next_elem = arrayKeys[j].next_elem;