diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-10 22:25:26 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-04-10 22:25:26 +0000 |
commit | 4e82a954764af0b03c54cd4db422a6b4e585e4e8 (patch) | |
tree | 672d349e0181ca7eeeedca63b08ab8b62e0d8750 /src/backend/executor/nodeBitmapIndexscan.c | |
parent | f260edb144c1e3f33d5ecc3d00d5359ab675d238 (diff) | |
download | postgresql-4e82a954764af0b03c54cd4db422a6b4e585e4e8.tar.gz postgresql-4e82a954764af0b03c54cd4db422a6b4e585e4e8.zip |
Replace "amgetmulti" AM functions with "amgetbitmap", in which the whole
indexscan always occurs in one call, and the results are returned in a
TIDBitmap instead of a limited-size array of TIDs. This should improve
speed a little by reducing AM entry/exit overhead, and it is necessary
infrastructure if we are ever to support bitmap indexes.
In an only slightly related change, add support for TIDBitmaps to preserve
(somewhat lossily) the knowledge that particular TIDs reported by an index
need to have their quals rechecked when the heap is visited. This facility
is not really used yet; we'll need to extend the forced-recheck feature to
plain indexscans before it's useful, and that hasn't been coded yet.
The intent is to use it to clean up 8.3's horrid @@@ kluge for text search
with weighted queries. There might be other uses in future, but that one
alone is sufficient reason.
Heikki Linnakangas, with some adjustments by me.
Diffstat (limited to 'src/backend/executor/nodeBitmapIndexscan.c')
-rw-r--r-- | src/backend/executor/nodeBitmapIndexscan.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/backend/executor/nodeBitmapIndexscan.c b/src/backend/executor/nodeBitmapIndexscan.c index fd56e862df6..a2b2700723c 100644 --- a/src/backend/executor/nodeBitmapIndexscan.c +++ b/src/backend/executor/nodeBitmapIndexscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.25 2008/01/01 19:45:49 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.26 2008/04/10 22:25:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,11 +37,8 @@ Node * MultiExecBitmapIndexScan(BitmapIndexScanState *node) { -#define MAX_TIDS 1024 TIDBitmap *tbm; IndexScanDesc scandesc; - ItemPointerData tids[MAX_TIDS]; - int32 ntids; double nTuples = 0; bool doscan; @@ -91,23 +88,14 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node) */ while (doscan) { - bool more = index_getmulti(scandesc, tids, MAX_TIDS, &ntids); - - if (ntids > 0) - { - tbm_add_tuples(tbm, tids, ntids); - nTuples += ntids; - } + nTuples += (double) index_getbitmap(scandesc, tbm); CHECK_FOR_INTERRUPTS(); - if (!more) - { - doscan = ExecIndexAdvanceArrayKeys(node->biss_ArrayKeys, - node->biss_NumArrayKeys); - if (doscan) /* reset index scan */ - index_rescan(node->biss_ScanDesc, node->biss_ScanKeys); - } + doscan = ExecIndexAdvanceArrayKeys(node->biss_ArrayKeys, + node->biss_NumArrayKeys); + if (doscan) /* reset index scan */ + index_rescan(node->biss_ScanDesc, node->biss_ScanKeys); } /* must provide our own instrumentation support */ @@ -321,10 +309,10 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate, int eflags) * Initialize scan descriptor. */ indexstate->biss_ScanDesc = - index_beginscan_multi(indexstate->biss_RelationDesc, - estate->es_snapshot, - indexstate->biss_NumScanKeys, - indexstate->biss_ScanKeys); + index_beginscan_bitmap(indexstate->biss_RelationDesc, + estate->es_snapshot, + indexstate->biss_NumScanKeys, + indexstate->biss_ScanKeys); /* * all done. |