我的场景似乎非常简单,但由于某种原因,我的查询总是进行 seq 扫描,并且不使用为表定义的排序键。
SELECT *
FROM table1
WHERE md_event_time between '2017-07-23 00:00:00' AND '2017-07-27 23:59:00'
Run Code Online (Sandbox Code Playgroud)
where 子句中的字段显示为表 info 中的排序键。解释:
XN Seq Scan on table1 (cost=0.00..0.00 rows=1 width=20)
Filter: ((md_event_time <= '2017-07-27 23:59:00'::timestamp without time zone) AND
(md_event_time >= '2017-07-23 00:00:00'::timestamp without time zone))
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏。