diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-20 15:48:36 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-20 15:48:36 +0000 |
commit | 9d64632144034cd6b0a32bad1c3a305008149754 (patch) | |
tree | 3ffabef3865521ea9a6e48e7e2213c369ff01abc /src/backend/executor/nodeBitmapIndexscan.c | |
parent | de4fbfadc50efe16cc05ea929bf5b408143d23fa (diff) | |
download | postgresql-9d64632144034cd6b0a32bad1c3a305008149754.tar.gz postgresql-9d64632144034cd6b0a32bad1c3a305008149754.zip |
Minor performance improvement: avoid unnecessary creation/unioning of
bitmaps for multiple indexscans. Instead just let each indexscan add
TIDs directly into the BitmapOr node's result bitmap.
Diffstat (limited to 'src/backend/executor/nodeBitmapIndexscan.c')
-rw-r--r-- | src/backend/executor/nodeBitmapIndexscan.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/backend/executor/nodeBitmapIndexscan.c b/src/backend/executor/nodeBitmapIndexscan.c index 3ed03eb7cb8..0c802ea49b0 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.1 2005/04/19 22:35:12 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.2 2005/04/20 15:48:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -63,9 +63,21 @@ MultiExecBitmapIndexScan(BitmapIndexScanState *node) scandesc = node->biss_ScanDesc; /* - * Prepare result bitmap + * Prepare the result bitmap. Normally we just create a new one to pass + * back; however, our parent node is allowed to store a pre-made one + * into node->biss_result, in which case we just OR our tuple IDs into + * the existing bitmap. (This saves needing explicit UNION steps.) */ - tbm = tbm_create(work_mem * 1024L); + if (node->biss_result) + { + tbm = node->biss_result; + node->biss_result = NULL; /* reset for next time */ + } + else + { + /* XXX should we use less than work_mem for this? */ + tbm = tbm_create(work_mem * 1024L); + } /* * Get TIDs from index and insert into bitmap @@ -271,6 +283,9 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate) indexstate->ss.ps.plan = (Plan *) node; indexstate->ss.ps.state = estate; + /* normally we don't make the result bitmap till runtime */ + indexstate->biss_result = NULL; + /* * Miscellaneous initialization * |