diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-02 20:50:48 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2010-12-02 20:51:37 -0500 |
commit | d583f10b7e0b9e1ed18f339f3177ed42ac2f7570 (patch) | |
tree | dab8027658ca6bf21b0199c15c5f775578d645c9 /src/backend/executor/nodeBitmapIndexscan.c | |
parent | d7e5d151daa2d5fe096953ae0b3530707b7c87f5 (diff) | |
download | postgresql-d583f10b7e0b9e1ed18f339f3177ed42ac2f7570.tar.gz postgresql-d583f10b7e0b9e1ed18f339f3177ed42ac2f7570.zip |
Create core infrastructure for KNNGIST.
This is a heavily revised version of builtin_knngist_core-0.9. The
ordering operators are no longer mixed in with actual quals, which would
have confused not only humans but significant parts of the planner.
Instead, ordering operators are carried separately throughout planning and
execution.
Since the API for ambeginscan and amrescan functions had to be changed
anyway, this commit takes the opportunity to rationalize that a bit.
RelationGetIndexScan no longer forces a premature index_rescan call;
instead, callers of index_beginscan must call index_rescan too. Aside from
making the AM-side initialization logic a bit less peculiar, this has the
advantage that we do not make a useless extra am_rescan call when there are
runtime key values. AMs formerly could not assume that the key values
passed to amrescan were actually valid; now they can.
Teodor Sigaev and Tom Lane
Diffstat (limited to 'src/backend/executor/nodeBitmapIndexscan.c')
-rw-r--r-- | src/backend/executor/nodeBitmapIndexscan.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/backend/executor/nodeBitmapIndexscan.c b/src/backend/executor/nodeBitmapIndexscan.c index 97ce0dde294..573e294882c 100644 --- a/src/backend/executor/nodeBitmapIndexscan.c +++ b/src/backend/executor/nodeBitmapIndexscan.c @@ -95,7 +95,9 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node) doscan = ExecIndexAdvanceArrayKeys(node->biss_ArrayKeys, node->biss_NumArrayKeys); if (doscan) /* reset index scan */ - index_rescan(node->biss_ScanDesc, node->biss_ScanKeys); + index_rescan(node->biss_ScanDesc, + node->biss_ScanKeys, node->biss_NumScanKeys, + NULL, 0); } /* must provide our own instrumentation support */ @@ -147,7 +149,9 @@ ExecReScanBitmapIndexScan(BitmapIndexScanState *node) /* reset index scan */ if (node->biss_RuntimeKeysReady) - index_rescan(node->biss_ScanDesc, node->biss_ScanKeys); + index_rescan(node->biss_ScanDesc, + node->biss_ScanKeys, node->biss_NumScanKeys, + NULL, 0); } /* ---------------------------------------------------------------- @@ -256,6 +260,8 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags) * Initialize index-specific scan state */ indexstate->biss_RuntimeKeysReady = false; + indexstate->biss_RuntimeKeys = NULL; + indexstate->biss_NumRuntimeKeys = 0; /* * build the index scan keys from the index qualification @@ -264,6 +270,7 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags) indexstate->biss_RelationDesc, node->scan.scanrelid, node->indexqual, + false, &indexstate->biss_ScanKeys, &indexstate->biss_NumScanKeys, &indexstate->biss_RuntimeKeys, @@ -297,8 +304,17 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags) indexstate->biss_ScanDesc = index_beginscan_bitmap(indexstate->biss_RelationDesc, estate->es_snapshot, - indexstate->biss_NumScanKeys, - indexstate->biss_ScanKeys); + indexstate->biss_NumScanKeys); + + /* + * If no run-time keys to calculate, go ahead and pass the scankeys to + * the index AM. + */ + if (indexstate->biss_NumRuntimeKeys == 0 && + indexstate->biss_NumArrayKeys == 0) + index_rescan(indexstate->biss_ScanDesc, + indexstate->biss_ScanKeys, indexstate->biss_NumScanKeys, + NULL, 0); /* * all done. |