gpt4 book ai didi

postgresql - PostgreSQL 什么时候自动为表创建位图索引?

转载 作者:行者123 更新时间:2023-11-29 14:09:08 25 4
gpt4 key购买 nike

PostgreSQL 什么时候自动为表创建位图索引?

我从PostgreSQL' documentation看到了以下例子,想知道为什么改变 WHERE 中的值会有所不同?谢谢。

EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 7000;
QUERY PLAN
------------------------------------------------------------
Seq Scan on tenk1 (cost=0.00..483.00 rows=7001 width=244)
Filter: (unique1 < 7000)

EXPLAIN SELECT * FROM tenk1 WHERE unique1 < 100;
QUERY PLAN
------------------------------------------------------------------------------
Bitmap Heap Scan on tenk1 (cost=5.07..229.20 rows=101 width=244)
Recheck Cond: (unique1 < 100)
-> Bitmap Index Scan on tenk1_unique1 (cost=0.00..5.04 rows=101
width=0)
Index Cond: (unique1 < 100)

最佳答案

Postgres 没有“位图索引”。

您看到的是在扫描索引时使用位图的“索引扫描”。

Tom Lane's answer在邮件列表上解释得很好:

A plain Index Scan fetches one tuple-pointer at a time from the index, and immediately visits that tuple in the table. A bitmap scan fetches all the tuple-pointers from the index in one go, sorts them using an in-memory "bitmap" data structure, and then visits the table tuples in physical tuple-location order.

另见这个问题 https://dba.stackexchange.com/questions/119386以获得更详细的解释。

关于postgresql - PostgreSQL 什么时候自动为表创建位图索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50938951/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com