CREATE INDEX idx_e_d ON public.expense USING btree (date);
explain select * from "public"."expense" where date > '2018-12-19'
Seq Scan on expense (cost=0.00..15133.15 rows=181367 width=41)
Filter: (date > '2018-12-19 00:00:00'::timestamp without time zone)
explain select * from "public"."expense" where date > '2018-12-20'
Bitmap Heap Scan on expense (cost=5245.18..14770.65 rows=162678 width=41)
Recheck Cond: (date > '2018-12-20 00:00:00'::timestamp without time zone)
-> Bitmap Index Scan on idx_e_d (cost=0.00..5204.51 rows=162678 width=0)
Index Cond: (date > '2018-12-20 00:00:00'::timestamp without time zone)
日期差一天,不走索引,用的是阿里云的 postgresql 9.4 2 核 4g
1
zbinlin 2018-12-29 12:32:13 +08:00
|
2
EchoUtopia 2018-12-29 16:29:08 +08:00
可能是 postgres 觉得数据量大了走索引不划算,因为还要回表
|