执行以下代码
这本没有什么问题,现在加上索引
create table t1(c1 int4);
insert into t1 select generate_series(1,10);
explain analyze select * from t1 where c1 =4
显示为
"Seq Scan on t1 (cost=0.00..40.00 rows=12 width=4) (actual time=0.007..0.007 rows=1 loops=1)"
" Filter: (c1 = 4)"
"Total runtime: 0.022 ms"
这本没有什么问题,现在加上索引
create index t1_index on t1 (c1);
explain analyze select * from t1 where c1 =4
显示依然为
"Seq Scan on t1 (cost=0.00..1.13 rows=1 width=4) (actual time=0.013..0.015 rows=1 loops=1)"
" Filter: (c1 = 4)"
"Total runtime: 0.050 ms"
执行计划并未改变依然为全表扫描加filter!
那索引目的何在?使用如下代码强制走索引测试
<