1. 程式人生 > >postgresql----唯一索引,表示式索引,部分索引

postgresql----唯一索引,表示式索引,部分索引

複製程式碼
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';
                                                              QUERY 
PLAN ------------------------------------------------------------------------------------------------------------------------------------- - 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)
複製程式碼