{"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","derived_content_hash":"302fe58cd0bf9f19d16fd7d366b5469a7636165184c39e60fa6f1595261178e6","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."],"description_zh":"扫描索引并生成匹配元组位置的位图。","description_zh_html":"\u003cp\u003e扫描索引并生成匹配元组位置的位图。\u003c/p\u003e\u003cp\u003e核心节点标识：\u003ccode\u003eT_BitmapIndexScan\u003c/code\u003e；EXPLAIN 名称：\u003ccode\u003eBitmap Index Scan\u003c/code\u003e。\u003c/p\u003e\u003cp\u003e本版本源码中的并行执行或观测回调：\u003ccode\u003eExecBitmapIndexScanEstimate, ExecBitmapIndexScanInitializeDSM, ExecBitmapIndexScanInitializeWorker, ExecBitmapIndexScanRetrieveInstrumentation\u003c/code\u003e。回调的存在不表示该节点必然支持共享并行扫描；在并行工作进程中执行也不等于具有并行感知能力。\u003c/p\u003e\u003ch3\u003e同版本中文手册节选\u003c/h3\u003e\u003cp\u003e\n    可以使用 \u003ccode class=\"command\"\u003eEXPLAIN\u003c/code\u003e 的 \u003ccode class=\"literal\"\u003eANALYZE\u003c/code\u003e 选项来检查规划器估计值的准确性。启用该选项后，\u003ccode class=\"command\"\u003eEXPLAIN\u003c/code\u003e 会实际执行查询，然后显示各个计划节点累计的真实行计数和真实运行时间，同时也保留普通 \u003ccode class=\"command\"\u003eEXPLAIN\u003c/code\u003e 会显示的估计值。例如，可能会得到如下结果：\n\n\u003c/p\u003e\u003cp\u003e\n\n    注意，\u003cspan class=\"quote\"\u003e“\u003cspan class=\"quote\"\u003eactual time\u003c/span\u003e”\u003c/span\u003e值以毫秒的真实时间表示，而 \u003ccode class=\"literal\"\u003ecost\u003c/code\u003e 估计值则以任意单位表示，因此二者通常不会直接对应。通常最值得关注的是估计行数是否与实际情况足够接近。在这个示例中，估计值完全命中，但在实践中这其实相当少见。\n   \u003c/p\u003e\u003cp\u003e\n    在某些查询计划中，一个子计划节点可能会执行多次。例如，上面那个嵌套循环计划中的内侧索引扫描会对外侧的每一行执行一次。在这种情况下，\u003ccode class=\"literal\"\u003eloops\u003c/code\u003e 值报告的是该节点的总执行次数，而 actual time 和 rows 显示的是每次执行的平均值。这样做是为了让这些数字更容易与代价估计的展示方式相比较。将它们乘以 \u003ccode class=\"literal\"\u003eloops\u003c/code\u003e 值，就能得到该节点实际消耗的总时间。在上面的示例中，执行 \u003ccode class=\"literal\"\u003etenk2\u003c/code\u003e 上的索引扫描总共花费了 0.030 毫秒。\n   \u003c/p\u003e\u003cp\u003e\n    在某些情况下，\u003ccode class=\"command\"\u003eEXPLAIN ANALYZE\u003c/code\u003e 会显示除计划节点执行时间和行计数之外的额外执行统计信息。例如，Sort 和 Hash 节点会提供更多信息：\n\n\u003c/p\u003e\u003cp\u003e\u003ca href=\"/zh/docs/18/using-explain.html#USING-EXPLAIN-ANALYZE\"\u003e查看完整中文手册与上下文\u003c/a\u003e。\u003c/p\u003e\u003cp\u003e本页开头的中文说明为 PG.CENTER 对编辑说明的翻译；手册节选保留对应版本中文文档原文。源码信息及手册示例不代表重新进行过运行测试。\u003c/p\u003e","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"}],"facts_zh":[{"label":"核心节点标签","value":"T_BitmapIndexScan"},{"label":"结构化 EXPLAIN 节点类型","value":"Bitmap Index Scan"},{"label":"输入","value":"索引"},{"label":"输出","value":"元组位置位图，不是元组流"},{"label":"执行器初始化函数","value":"ExecInitBitmapIndexScan"},{"label":"内存机制","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"}],"sections_zh":[{"paragraphs":["结构化格式使用上述 Node Type。文本格式名称还可能包含操作、策略、连接类型、扫描方向或聚合阶段属性。","此源码记录的文本名称：Bitmap Index Scan.","并行感知与并行安全是不同的计划属性。在并行工作进程内运行的节点不一定是并行感知节点。"],"title":"EXPLAIN 名称与属性"},{"paragraphs":["此节点按基于 work_mem 的预算分配元组位置位图。位图可以保留页级有损条目，而不记录每个元组位置，因此仍可能需要堆重检。"],"title":"内存与临时存储"},{"paragraphs":["以下源码回调可以协调执行或收集工作进程的测量数据。回调存在不代表该节点普遍支持共享并行扫描或共享状态。","此构建的回调：ExecBitmapIndexScanEstimate, ExecBitmapIndexScanInitializeDSM, ExecBitmapIndexScanInitializeWorker, ExecBitmapIndexScanRetrieveInstrumentation."],"title":"并行执行与运行信息采集"},{"paragraphs":["Index Scan 节点（以及 Bitmap Index Scan 和 Index-Only Scan 节点）会显示一行 “ Index Searches ” ，用于报告跨 所有 节点执行/ loops 的总搜索次数：","这里的 Bitmap Index Scan 节点需要分别执行 4 次索引搜索。对于谓词 IN 结构中的每个整数值，扫描都需要从 tenk1_thous_tenthous 索引的根页开始搜索一次。不过，索引搜索次数往往不会与查询谓词存在如此简单的对应关系："],"title":"同版本手册说明"},{"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":["示例摘自 PostgreSQL 18.6 手册；本百科未实际执行此示例。","现在进一步收紧条件："],"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":["示例摘自 PostgreSQL 18.6 手册；本百科未实际执行此示例。","现在向 WHERE 子句再添加一个条件："],"source":{"label":"PostgreSQL 18.6 · using-explain","path":"using-explain.html","sha256":"60040c30180093418a0affe56dd27dff9df2504b705b38039589e458bf5c31ed","url":"/docs/18/using-explain.html#USING-EXPLAIN-BASICS"}}],"title":"本版手册中的示例"},{"paragraphs":["nodeBitmapIndexscan.c：支持关系位图索引扫描的例程。","如果有运行时键且尚未设置，现在就设置。数组键也视为运行时键；注意，如果 ExecReScan 返回后 biss_RuntimeKeysReady 仍为 false，则存在空数组键，此时不应执行任何操作。","准备结果位图。通常创建新位图返回；但父节点可以预先在 node-\u003ebiss_result 中存入位图，此时直接将元组 ID 按位 OR 合并到现有位图，省去显式 UNION 步骤。","重新计算依赖运行时信息的扫描键值，然后重新扫描被索引的关系。","重置运行时键上下文，避免每次扫描外侧元组时泄漏内存。这里假定每次调用都重新计算所有运行时键。"],"title":"执行器实现说明"},{"code":"case T_BitmapIndexScan:\n\t\t\tpname = sname = \"Bitmap Index Scan\";\n\t\t\tbreak;","title":"核心源码中的 EXPLAIN 标识"}],"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"}],"tables_zh":[{"columns":[{"key":"label","label":"文本格式标签"},{"key":"identity","label":"结构化节点标识"}],"key":"explain-labels","rows":[{"identity":"Bitmap Index Scan","label":"Bitmap Index Scan"}],"title":"本构建中的 EXPLAIN 标签"}],"zh_from":{"authored_translation":"authored-translation-of-reviewed-guidance","body_sha256":"d8fe857fdab0fdf71ab6903a7a530f85914366f0a0f720bfff56bc1941fa7523","kind":"same-version-chinese-manual-with-authored-translation-of-reviewed-guidance","manual":{"anchor":"USING-EXPLAIN-ANALYZE","build_id":107,"extraction":"concept-introduction","fragment_sha256":"bd141e848f811d1c8513c49e1a6510edcdcbaac6c111b76d7e421d315346e90d","locale":"zh-Hans","page_key":"using-explain.html","source_hash":"d2f749744b3ac5aa2eb0154f295e8163903cd20fcc130c74c6172cdf2ae3a9df","source_revision":"unknown:rendered-translation-baseline","translated_from_revision":null,"translation_revision":"git:b1b500221dbe5437cfca004d6b04d3f6e422765d;html-sha256:08e987a66af27b98444a8057c256314eafa13611a3fb9e888214fc436824244b","url":"/zh/docs/18/using-explain.html#USING-EXPLAIN-ANALYZE","version":"18"},"runtime_rerun":false,"source_facts_revision":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f"}},"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":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
