postgresql - 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))"
...并且我们有一个名称相似的表和索引,它正确地使用了索引。
解决方案
推荐阅读
- php - 写入数据库(php/mySQL)
- html - 如何创建两个可点击的相交图像?
- vba - 获取特定对象 vba 的库名称
- html - 使用 HTML、CSS 绘制三角形和形状
- c# - 如何使用 CRUD 功能创建连接到数据库的 Blazor WebAssembly 网站
- mysql - 扩展后连接到 apache 的问题,我在 Kubernetes 上的有状态数据库
- angular - 单击角度 12 中的每个 formArray 元素后,如何禁用 formArray 的特定单击事件?
- c++ - How unused default member initializer can change program behavior in C++?
- hibernate - 如何在休眠 4 中使用 Dto 而不是 Model 类
- extjs - 如何从来自 json 的商店上传动态数据