首页 > 解决方案 > Postgres SELECT查询不使用索引

问题描述

我在一个相当大的数据表(1亿+行)上创建了一个索引

create index on web_responses_rebuild_2019_09 (response_time)

当我对数据的简单查询运行解释时,它不使用索引,而是进行全表扫描

explain select *
from web_responses_rebuild_2019_09
where response_time between 1567398218
    and 1567398220;

结果:

QUERY PLAN
"Seq Scan on web_responses_rebuild_2019_09  (cost=10000000000.00..10044668761.32 rows=300 width=734)"
"  Filter: ((response_time >= 1567398218) AND (response_time <= 1567398220))"

...并且我们有一个名称相似的表和索引,它正确地使用了索引。

标签: postgresql

解决方案


推荐阅读