diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-28 22:47:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-08-28 22:47:20 +0000 |
commit | 46a0eee3006b11a15b73426c8146ed5ab32e1d62 (patch) | |
tree | 84e646e836446437c7fd310fd0aaf167b561e4dc /src/backend/executor/nodeBitmapAnd.c | |
parent | 75e90bbf69efb3cee8d3af9c07d345dd9540a7cc (diff) | |
download | postgresql-46a0eee3006b11a15b73426c8146ed5ab32e1d62.tar.gz postgresql-46a0eee3006b11a15b73426c8146ed5ab32e1d62.zip |
Tweak nodeBitmapAnd to stop evaluating sub-plan scans if it finds it's
got an empty bitmap after any step; the remaining subplans can no longer
affect the result. Per a suggestion from Ilia Kantor.
Diffstat (limited to 'src/backend/executor/nodeBitmapAnd.c')
-rw-r--r-- | src/backend/executor/nodeBitmapAnd.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/backend/executor/nodeBitmapAnd.c b/src/backend/executor/nodeBitmapAnd.c index 1d5d94fc3f8..939062d4d6c 100644 --- a/src/backend/executor/nodeBitmapAnd.c +++ b/src/backend/executor/nodeBitmapAnd.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapAnd.c,v 1.2 2005/04/20 15:48:36 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapAnd.c,v 1.3 2005/08/28 22:47:20 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -143,6 +143,16 @@ MultiExecBitmapAnd(BitmapAndState *node) tbm_intersect(result, subresult); tbm_free(subresult); } + + /* + * If at any stage we have a completely empty bitmap, we can fall + * out without evaluating the remaining subplans, since ANDing them + * can no longer change the result. (Note: the fact that indxpath.c + * orders the subplans by selectivity should make this case more + * likely to occur.) + */ + if (tbm_is_empty(result)) + break; } if (result == NULL) |