软件下载吧文章资讯

分类分类

PostgreSQL索引失效会发生什么

2024-02-14 10:20作者:下载吧

前段时间碰到个奇怪的索引失效的问题,实际情况类似下面这样:

bill=# begin;
BEGIN
bill=*# create index idx_t1 on t1(id);
CREATE INDEX
bill=*# explain select * from t1 where id = 1;
QUERY PLAN
—————————————————-
Seq Scan on t1 (cost=0.00..25.88 rows=6 width=36)
Filter: (id = 1)
(2 rows)

bill=*# end;
COMMIT
bill=# explain select * from t1 where id = 1;
QUERY PLAN
———————————————————————
Bitmap Heap Scan on t1 (cost=1.50..7.01 rows=6 width=36)
Recheck Cond: (id = 1)
-> Bitmap Index Scan on idx_t1 (cost=0.00..1.50 rows=6 width=0)
Index Cond: (id = 1)
(4 rows)

展开全部

相关文章

说两句网友评论
    我要跟贴
    取消