{"Entry":{"collection":"plan","key":"bitmap-heap-scan","name":"Bitmap Heap Scan","aliases":["Bitmap Heap Scan","BitmapHeapScan","T_BitmapHeapScan"],"metadata":{"aliases":["Bitmap Heap Scan","BitmapHeapScan","T_BitmapHeapScan"],"category":"Scan","content_hash":"f367ec0c2e303f54fe421e2de5843b2f1b11e9e76c9ff4dd8073d1b0de9525ed","imported_at":"2026-09-30T00:40:44.204953+08:00","name":"Bitmap Heap Scan","name_zh":"BitmapHeapScan","slug":"bitmap-heap-scan","summary":"Visits heap pages selected by a bitmap and performs required rechecks."}},"Definition":{"Collection":"plan","Key":"bitmap-heap-scan","SourceDatabase":"center","Version":"18","SourceTable":"plan_node","SourceKey":"bitmap-heap-scan","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"comparison_data":{"initializer":"ExecInitBitmapHeapScan","memory_mechanism":"unclassified","node_tag":"T_BitmapHeapScan","parallel_callbacks":["ExecBitmapHeapEstimate","ExecBitmapHeapInitializeDSM","ExecBitmapHeapInitializeWorker","ExecBitmapHeapReInitializeDSM","ExecBitmapHeapRetrieveInstrumentation"],"partial_modes":[],"strategies":[],"text_names":["Bitmap Heap Scan"]},"comparison_hash":"f7ee070f7f36c2ed7f3e237eb0933d70972eaf9860d38070438efebcf8ec6e71","description":["Visits heap pages selected by a bitmap and performs required rechecks."],"evidence_kind":"source and documentation","explain_names":["Bitmap Heap Scan"],"explain_prefixes":["Parallel","Async"],"facts":[{"label":"Core node tag","value":"T_BitmapHeapScan"},{"label":"Structured EXPLAIN Node Type","value":"Bitmap Heap Scan"},{"label":"Inputs","value":"A tuple-location bitmap and relation"},{"label":"Output","value":"Qualified heap tuples"},{"label":"Executor initializer","value":"ExecInitBitmapHeapScan"},{"label":"Memory mechanism","value":"unclassified"}],"memory":{"description":"This extraction does not assign a universal memory limit or spill policy to this node. Inspect the same-build implementation and its expressions or provider.","evidence":[{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/nodeBitmapHeapscan.c","path":"src/backend/executor/nodeBitmapHeapscan.c","sha256":"0c49bbf89f6614af08dbcea2a1776abc79db23e523e8c1fc852a42215f202206","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}],"mechanism":"unclassified","source_notes":["If we are using lossy info, we have to recheck the qual conditions at every tuple."]},"node_tag":"T_BitmapHeapScan","parallel_callbacks":["ExecBitmapHeapEstimate","ExecBitmapHeapInitializeDSM","ExecBitmapHeapInitializeWorker","ExecBitmapHeapReInitializeDSM","ExecBitmapHeapRetrieveInstrumentation"],"partial_modes":[],"related":[{"label":"EXPLAIN","url":"/wiki/sql/explain/?v=18"},{"label":"Using EXPLAIN","url":"/docs/18/using-explain.html"},{"label":"Parallel plans","url":"/docs/18/parallel-plans.html"},{"label":"enable_bitmapscan","url":"/wiki/guc/enable_bitmapscan/?v=18"}],"release":{"channel":"stable","label":"18.6","major":"18","ref":"PostgreSQL 18.6 source archive","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_snapshot_utc":"","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},"runtime_verified":false,"sections":[{"paragraphs":["Structured formats use the Node Type above. Text-format spellings can also include operation, strategy, join type, scan direction or aggregation-stage attributes.","Text names recorded by this source: Bitmap Heap Scan.","Parallel-aware and parallel-safe are different plan properties. A node running inside a parallel worker is not necessarily a parallel-aware node."],"title":"EXPLAIN names and attributes"},{"paragraphs":["This extraction does not assign a universal memory limit or spill policy to this node. Inspect the same-build implementation and its expressions or provider.","If we are using lossy info, we have to recheck the qual conditions at every tuple."],"title":"Memory and temporary storage"},{"paragraphs":["The source callbacks below can coordinate execution or collect worker instrumentation. Their presence is not a blanket claim that this node supports a shared parallel scan or shared state.","Callbacks in this build: ExecBitmapHeapEstimate, ExecBitmapHeapInitializeDSM, ExecBitmapHeapInitializeWorker, ExecBitmapHeapReInitializeDSM, ExecBitmapHeapRetrieveInstrumentation."],"title":"Parallel execution and instrumentation"},{"paragraphs":["In a parallel bitmap heap scan , one process is chosen as the leader. That process performs a scan of one or more indexes and builds a bitmap indicating which table blocks need to be visited. These blocks are then divided among the cooperating processes as in a parallel sequential scan. In other words, the heap scan is performed in parallel, but the underlying index scan is not."],"title":"Same-version manual discussion"},{"blocks":[{"code":"EXPLAIN SELECT * FROM tenk1 WHERE unique1 \u003c 100;\n\n                                  QUERY PLAN\n------------------------------------------------------------------------------\n Bitmap Heap Scan on tenk1  (cost=5.06..224.98 rows=100 width=244)\n   Recheck Cond: (unique1 \u003c 100)\n   -\u003e  Bitmap Index Scan on tenk1_unique1  (cost=0.00..5.04 rows=100 width=0)\n         Index Cond: (unique1 \u003c 100)","paragraphs":["Example copied from the PostgreSQL 18.6 manual; it was not executed for this collection.","Now, let's make the condition more restrictive:"],"source":{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}},{"code":"EXPLAIN SELECT * FROM tenk1 WHERE unique1 \u003c 100 AND stringu1 = 'xxx';\n\n                                  QUERY PLAN\n------------------------------------------------------------------------------\n Bitmap Heap Scan on tenk1  (cost=5.04..225.20 rows=1 width=244)\n   Recheck Cond: (unique1 \u003c 100)\n   Filter: (stringu1 = 'xxx'::name)\n   -\u003e  Bitmap Index Scan on tenk1_unique1  (cost=0.00..5.04 rows=100 width=0)\n         Index Cond: (unique1 \u003c 100)","paragraphs":["Example copied from the PostgreSQL 18.6 manual; it was not executed for this collection.","Now let's add another condition to the WHERE clause:"],"source":{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}}],"title":"Examples from this manual build"},{"paragraphs":["nodeBitmapHeapscan.c Routines to support bitmapped scans of relations","NOTE: it is critical that this plan type only be used with MVCC-compliant snapshots (ie, regular snapshots, not SnapshotAny or one of the other special snapshots). The reason is that since index and heap scans are decoupled, there can be no assurance that the index tuple prompting a visit to a particular heap TID still exists when the visit is made. Therefore the tuple might not exist anymore either (which is OK because heap_fetch will cope) --- but worse, the tuple slot could have been re-used for a newer tuple. With an MVCC snapshot the newer tuple is certain to fail the time qual and so it will not be mistakenly returned, but with anything else we might return a tuple that doesn't meet the required index qual conditions.","Do the underlying index scan, build the bitmap, set up the parallel state needed for parallel workers to iterate through the bitmap, and set up the underlying table scan descriptor.","The leader will immediately come out of the function, but others will be blocked until leader populates the TBM and wakes them up.","Prepare to iterate over the TBM. This will return the dsa_pointer of the iterator state which will be used by multiple processes to iterate jointly."],"title":"Executor implementation notes"},{"code":"case T_BitmapHeapScan:\n\t\t\tpname = sname = \"Bitmap Heap Scan\";\n\t\t\tbreak;","title":"EXPLAIN identity in core source"}],"source_inventory":{"executor":"src/backend/executor/execProcnode.c","explain":"src/backend/commands/explain.c","implementation":"src/backend/executor/nodeBitmapHeapscan.c"},"sources":[{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/commands/explain.c:1453","line":1453,"path":"src/backend/commands/explain.c","sha256":"34c86d6070224a0e981efef51f79101d6d505e5874f1684ace183034bab14bb4","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/execProcnode.c:234","line":234,"path":"src/backend/executor/execProcnode.c","sha256":"f8a06a3f539077249b20664b2812433db6d7bd12b2c0ca633525db43d06f112a","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/nodeBitmapHeapscan.c","path":"src/backend/executor/nodeBitmapHeapscan.c","sha256":"0c49bbf89f6614af08dbcea2a1776abc79db23e523e8c1fc852a42215f202206","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/include/nodes/plannodes.h","path":"src/include/nodes/plannodes.h","sha256":"52422b327a8049fbbb20d8b96008a0fc0a6fafa60f7eff3c695d5b2e83830120","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18.6 · parallel-plans","path":"parallel-plans.html","sha256":"62207d207bead82b01b59dc119c4f95856f08655cc11d4699a05a40867ed2070","url":"/docs/18/parallel-plans.html#PARALLEL-SCANS"},{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}],"strategies":[],"tables":[{"columns":[{"key":"label","label":"Text-format label"},{"key":"identity","label":"Structured node identity"}],"key":"explain-labels","rows":[{"identity":"Bitmap Heap Scan","label":"Bitmap Heap Scan"}],"title":"EXPLAIN labels in this source build"}]},"ManualEvidence":{"release":{"channel":"stable","label":"18.6","major":"18","ref":"PostgreSQL 18.6 source archive","revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_snapshot_utc":"","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},"sources":[{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/commands/explain.c:1453","line":1453,"path":"src/backend/commands/explain.c","sha256":"34c86d6070224a0e981efef51f79101d6d505e5874f1684ace183034bab14bb4","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/execProcnode.c:234","line":234,"path":"src/backend/executor/execProcnode.c","sha256":"f8a06a3f539077249b20664b2812433db6d7bd12b2c0ca633525db43d06f112a","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/nodeBitmapHeapscan.c","path":"src/backend/executor/nodeBitmapHeapscan.c","sha256":"0c49bbf89f6614af08dbcea2a1776abc79db23e523e8c1fc852a42215f202206","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/include/nodes/plannodes.h","path":"src/include/nodes/plannodes.h","sha256":"52422b327a8049fbbb20d8b96008a0fc0a6fafa60f7eff3c695d5b2e83830120","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18.6 · parallel-plans","path":"parallel-plans.html","sha256":"62207d207bead82b01b59dc119c4f95856f08655cc11d4699a05a40867ed2070","url":"/docs/18/parallel-plans.html#PARALLEL-SCANS"},{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}]},"MeasuredEvidence":{"runtime_verified":false}},"Text":{"Collection":"plan","Key":"bitmap-heap-scan","SourceDatabase":"center","Version":"18","Locale":"en","Title":"Bitmap Heap Scan","Summary":"Visits heap pages selected by a bitmap and performs required rechecks.","BodyHTML":"\u003cp\u003eVisits heap pages selected by a bitmap and performs required rechecks.\u003c/p\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"67a240ed1df6440b294a8b9b0af0daac83d630bea5b35a673d8cfb668e8ce5bb","Payload":{"description":["Visits heap pages selected by a bitmap and performs required rechecks."],"related":[{"label":"EXPLAIN","url":"/wiki/sql/explain/?v=18"},{"label":"Using EXPLAIN","url":"/docs/18/using-explain.html"},{"label":"Parallel plans","url":"/docs/18/parallel-plans.html"},{"label":"enable_bitmapscan","url":"/wiki/guc/enable_bitmapscan/?v=18"}],"sections":[{"paragraphs":["Structured formats use the Node Type above. Text-format spellings can also include operation, strategy, join type, scan direction or aggregation-stage attributes.","Text names recorded by this source: Bitmap Heap Scan.","Parallel-aware and parallel-safe are different plan properties. A node running inside a parallel worker is not necessarily a parallel-aware node."],"title":"EXPLAIN names and attributes"},{"paragraphs":["This extraction does not assign a universal memory limit or spill policy to this node. Inspect the same-build implementation and its expressions or provider.","If we are using lossy info, we have to recheck the qual conditions at every tuple."],"title":"Memory and temporary storage"},{"paragraphs":["The source callbacks below can coordinate execution or collect worker instrumentation. Their presence is not a blanket claim that this node supports a shared parallel scan or shared state.","Callbacks in this build: ExecBitmapHeapEstimate, ExecBitmapHeapInitializeDSM, ExecBitmapHeapInitializeWorker, ExecBitmapHeapReInitializeDSM, ExecBitmapHeapRetrieveInstrumentation."],"title":"Parallel execution and instrumentation"},{"paragraphs":["In a parallel bitmap heap scan , one process is chosen as the leader. That process performs a scan of one or more indexes and builds a bitmap indicating which table blocks need to be visited. These blocks are then divided among the cooperating processes as in a parallel sequential scan. In other words, the heap scan is performed in parallel, but the underlying index scan is not."],"title":"Same-version manual discussion"},{"blocks":[{"code":"EXPLAIN SELECT * FROM tenk1 WHERE unique1 \u003c 100;\n\n                                  QUERY PLAN\n------------------------------------------------------------------------------\n Bitmap Heap Scan on tenk1  (cost=5.06..224.98 rows=100 width=244)\n   Recheck Cond: (unique1 \u003c 100)\n   -\u003e  Bitmap Index Scan on tenk1_unique1  (cost=0.00..5.04 rows=100 width=0)\n         Index Cond: (unique1 \u003c 100)","paragraphs":["Example copied from the PostgreSQL 18.6 manual; it was not executed for this collection.","Now, let's make the condition more restrictive:"],"source":{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}},{"code":"EXPLAIN SELECT * FROM tenk1 WHERE unique1 \u003c 100 AND stringu1 = 'xxx';\n\n                                  QUERY PLAN\n------------------------------------------------------------------------------\n Bitmap Heap Scan on tenk1  (cost=5.04..225.20 rows=1 width=244)\n   Recheck Cond: (unique1 \u003c 100)\n   Filter: (stringu1 = 'xxx'::name)\n   -\u003e  Bitmap Index Scan on tenk1_unique1  (cost=0.00..5.04 rows=100 width=0)\n         Index Cond: (unique1 \u003c 100)","paragraphs":["Example copied from the PostgreSQL 18.6 manual; it was not executed for this collection.","Now let's add another condition to the WHERE clause:"],"source":{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}}],"title":"Examples from this manual build"},{"paragraphs":["nodeBitmapHeapscan.c Routines to support bitmapped scans of relations","NOTE: it is critical that this plan type only be used with MVCC-compliant snapshots (ie, regular snapshots, not SnapshotAny or one of the other special snapshots). The reason is that since index and heap scans are decoupled, there can be no assurance that the index tuple prompting a visit to a particular heap TID still exists when the visit is made. Therefore the tuple might not exist anymore either (which is OK because heap_fetch will cope) --- but worse, the tuple slot could have been re-used for a newer tuple. With an MVCC snapshot the newer tuple is certain to fail the time qual and so it will not be mistakenly returned, but with anything else we might return a tuple that doesn't meet the required index qual conditions.","Do the underlying index scan, build the bitmap, set up the parallel state needed for parallel workers to iterate through the bitmap, and set up the underlying table scan descriptor.","The leader will immediately come out of the function, but others will be blocked until leader populates the TBM and wakes them up.","Prepare to iterate over the TBM. This will return the dsa_pointer of the iterator state which will be used by multiple processes to iterate jointly."],"title":"Executor implementation notes"},{"code":"case T_BitmapHeapScan:\n\t\t\tpname = sname = \"Bitmap Heap Scan\";\n\t\t\tbreak;","title":"EXPLAIN identity in core source"}],"tables":[{"columns":[{"key":"label","label":"Text-format label"},{"key":"identity","label":"Structured node identity"}],"key":"explain-labels","rows":[{"identity":"Bitmap Heap Scan","label":"Bitmap Heap Scan"}],"title":"EXPLAIN labels in this source build"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
