postgresql----唯一索引,表示式索引,部分索引
阿新 • • 發佈:2019-02-14
test=# create index idx_tbl_expression_a on tbl_expression using btree (a); CREATE INDEX test=# create index idx_tbl_expression_b on tbl_expression using btree (b); CREATE INDEX test=# test=# explain analyze select * from tbl_expression where a = 'TEST'; QUERYPLAN ------------------------------------------------------------------------------------------------------------------------------------- - Index Scan using idx_tbl_expression_a on tbl_expression (cost=0.29..8.30 rows=1 width=15) (actual time=0.130..0.130 rows=0 loops=1) Index Cond: ((a)::text = 'TEST'::text) Planning time: 0.667 ms Execution time: 0.168 ms (4 rows) test=# explain analyze select * from tbl_expression where b = 'you'; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------- - Index Scan using idx_tbl_expression_b on tbl_expression (cost=0.29..8.30 rows=1 width=15) (actual time=0.171..0.171 rows=0 loops=1) Index Cond: ((b)::text = 'you'::text) Planning time: 0.126 ms Execution time: 0.206 ms (4 rows)