{"Entry":{"collection":"plan","key":"bitmap-index-scan","name":"Bitmap Index Scan","aliases":["Bitmap Index Scan","BitmapIndexScan","T_BitmapIndexScan"],"metadata":{"aliases":["Bitmap Index Scan","BitmapIndexScan","T_BitmapIndexScan"],"category":"Bitmap","content_hash":"3199b7487fd6d632de557dbd929a6e3c17896619aeb18189f9f1fc3304906872","imported_at":"2026-09-30T00:40:44.014301+08:00","name":"Bitmap Index Scan","name_zh":"BitmapIndexScan","slug":"bitmap-index-scan","summary":"Scans an index and produces a bitmap of matching tuple locations."}},"Definition":{"Collection":"plan","Key":"bitmap-index-scan","SourceDatabase":"center","Version":"18","SourceTable":"plan_node","SourceKey":"bitmap-index-scan","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","Facts":{"comparison_data":{"initializer":"ExecInitBitmapIndexScan","memory_mechanism":"bitmap-lossification","node_tag":"T_BitmapIndexScan","parallel_callbacks":["ExecBitmapIndexScanEstimate","ExecBitmapIndexScanInitializeDSM","ExecBitmapIndexScanInitializeWorker","ExecBitmapIndexScanRetrieveInstrumentation"],"partial_modes":[],"strategies":[],"text_names":["Bitmap Index Scan"]},"comparison_hash":"08e8d1afde24882a70dccba204ec21bdcea148fa12f7f53d14a221b80af1cc37","description":["Scans an index and produces a bitmap of matching tuple locations."],"evidence_kind":"source and documentation","explain_names":["Bitmap Index Scan"],"explain_prefixes":["Parallel","Async"],"facts":[{"label":"Core node tag","value":"T_BitmapIndexScan"},{"label":"Structured EXPLAIN Node Type","value":"Bitmap Index Scan"},{"label":"Inputs","value":"An index"},{"label":"Output","value":"Tuple-location bitmap, not a tuple stream"},{"label":"Executor initializer","value":"ExecInitBitmapIndexScan"},{"label":"Memory mechanism","value":"bitmap-lossification"}],"memory":{"description":"The node allocates a tuple-location bitmap using a work_mem-derived budget. A bitmap can retain page-level lossy entries instead of every tuple location; heap rechecks then remain necessary.","evidence":[{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/executor/nodeBitmapIndexscan.c","path":"src/backend/executor/nodeBitmapIndexscan.c","sha256":"7eed6439851a24333252fcce6e7c71856e8da9bdaee78597401b11afdbb093c0","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/nodes/tidbitmap.c","path":"src/backend/nodes/tidbitmap.c","sha256":"e2453b7155d55db8c3a59bc929362f01d3f9692b0a483e5aa81a7b6c50db6102","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"}],"mechanism":"bitmap-lossification","source_notes":[]},"node_tag":"T_BitmapIndexScan","parallel_callbacks":["ExecBitmapIndexScanEstimate","ExecBitmapIndexScanInitializeDSM","ExecBitmapIndexScanInitializeWorker","ExecBitmapIndexScanRetrieveInstrumentation"],"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"},{"label":"work_mem","url":"/wiki/guc/work_mem/?v=18"},{"label":"Index AM","url":"/wiki/indexam/?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 Index 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":["The node allocates a tuple-location bitmap using a work_mem-derived budget. A bitmap can retain page-level lossy entries instead of every tuple location; heap rechecks then remain necessary."],"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: ExecBitmapIndexScanEstimate, ExecBitmapIndexScanInitializeDSM, ExecBitmapIndexScanInitializeWorker, ExecBitmapIndexScanRetrieveInstrumentation."],"title":"Parallel execution and instrumentation"},{"paragraphs":["Index Scan nodes (as well as Bitmap Index Scan and Index-Only Scan nodes) show an “ Index Searches ” line that reports the total number of searches across all node executions/ loops :","Here we see a Bitmap Index Scan node that needed 4 separate index searches. The scan had to search the index from the tenk1_thous_tenthous index root page once per integer value from the predicate's IN construct. However, the number of index searches often won't have such a simple correspondence to the query predicate:"],"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":["nodeBitmapIndexscan.c Routines to support bitmapped index scans of relations","If we have runtime keys and they've not already been set up, do it now. Array keys are also treated as runtime keys; note that if ExecReScan returns with biss_RuntimeKeysReady still false, then there is an empty array key so we should do nothing.","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-\u003ebiss_result, in which case we just OR our tuple IDs into the existing bitmap. (This saves needing explicit UNION steps.)","Recalculates the values of any scan keys whose value depends on information known at runtime, then rescans the indexed relation.","Reset the runtime-key context so we don't leak memory as each outer tuple is scanned. Note this assumes that we will recalculate *all* runtime keys on each call."],"title":"Executor implementation notes"},{"code":"case T_BitmapIndexScan:\n\t\t\tpname = sname = \"Bitmap Index 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/nodeBitmapIndexscan.c"},"sources":[{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/commands/explain.c:1450","line":1450,"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:229","line":229,"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/nodeBitmapIndexscan.c","path":"src/backend/executor/nodeBitmapIndexscan.c","sha256":"7eed6439851a24333252fcce6e7c71856e8da9bdaee78597401b11afdbb093c0","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"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/nodes/tidbitmap.c","path":"src/backend/nodes/tidbitmap.c","sha256":"e2453b7155d55db8c3a59bc929362f01d3f9692b0a483e5aa81a7b6c50db6102","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-ANALYZE"},{"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 Index Scan","label":"Bitmap Index 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:1450","line":1450,"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:229","line":229,"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/nodeBitmapIndexscan.c","path":"src/backend/executor/nodeBitmapIndexscan.c","sha256":"7eed6439851a24333252fcce6e7c71856e8da9bdaee78597401b11afdbb093c0","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"},{"archive_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","label":"src/backend/nodes/tidbitmap.c","path":"src/backend/nodes/tidbitmap.c","sha256":"e2453b7155d55db8c3a59bc929362f01d3f9692b0a483e5aa81a7b6c50db6102","url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-ANALYZE"},{"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-index-scan","SourceDatabase":"center","Version":"18","Locale":"en","Title":"Bitmap Index Scan","Summary":"Scans an index and produces a bitmap of matching tuple locations.","BodyHTML":"\u003cp\u003eScans an index and produces a bitmap of matching tuple locations.\u003c/p\u003e","SourceRevision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","ContentHash":"66c1e158c14a08b95a12428f71557cf68440da9f0e17063e4f9ef6cca02dff6e","Payload":{"description":["Scans an index and produces a bitmap of matching tuple locations."],"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"},{"label":"work_mem","url":"/wiki/guc/work_mem/?v=18"},{"label":"Index AM","url":"/wiki/indexam/?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 Index 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":["The node allocates a tuple-location bitmap using a work_mem-derived budget. A bitmap can retain page-level lossy entries instead of every tuple location; heap rechecks then remain necessary."],"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: ExecBitmapIndexScanEstimate, ExecBitmapIndexScanInitializeDSM, ExecBitmapIndexScanInitializeWorker, ExecBitmapIndexScanRetrieveInstrumentation."],"title":"Parallel execution and instrumentation"},{"paragraphs":["Index Scan nodes (as well as Bitmap Index Scan and Index-Only Scan nodes) show an “ Index Searches ” line that reports the total number of searches across all node executions/ loops :","Here we see a Bitmap Index Scan node that needed 4 separate index searches. The scan had to search the index from the tenk1_thous_tenthous index root page once per integer value from the predicate's IN construct. However, the number of index searches often won't have such a simple correspondence to the query predicate:"],"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":["nodeBitmapIndexscan.c Routines to support bitmapped index scans of relations","If we have runtime keys and they've not already been set up, do it now. Array keys are also treated as runtime keys; note that if ExecReScan returns with biss_RuntimeKeysReady still false, then there is an empty array key so we should do nothing.","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-\u003ebiss_result, in which case we just OR our tuple IDs into the existing bitmap. (This saves needing explicit UNION steps.)","Recalculates the values of any scan keys whose value depends on information known at runtime, then rescans the indexed relation.","Reset the runtime-key context so we don't leak memory as each outer tuple is scanned. Note this assumes that we will recalculate *all* runtime keys on each call."],"title":"Executor implementation notes"},{"code":"case T_BitmapIndexScan:\n\t\t\tpname = sname = \"Bitmap Index 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 Index Scan","label":"Bitmap Index 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}
