表达式索引 本文为您介绍如何管理表达式索引。 plaintext teledb create table tupper(id int,mc text); CREATE TABLE teledb create index tuppermc on tupper(mc); CREATE INDEX teledb insert into tupper select t,md5(t::text) from generateseries(1,10000) as t; INSERT 0 10000 teledb analyze tupper; ANALYZE teledb explain select from tupper where upper(mc)md5('1'); QUERY PLAN Remote Fast Query Execution (cost0.00..0.00 rows0 width0) Node/s: dn01, dn02 > Seq Scan on tupper (cost0.00..133.58 rows25 width37) Filter: (upper(mc) 'c4ca4238a0b923820dcc509a6f75849b'::text) (4 rows) teledb create index tuppermc on tupper(upper(mc)); ERROR: relation "tuppermc" already exists teledb create index tuppermc1 on tupper(upper(mc)); CREATE INDEX teledb explain select from tupper where upper(mc)md5('1'); QUERY PLAN Remote Fast Query Execution (cost0.00..0.00 rows0 width0) Node/s: dn01, dn02 > Bitmap Heap Scan on tupper (cost4.48..50.94 rows25 width37) Recheck Cond: (upper(mc) 'c4ca4238a0b923820dcc509a6f75849b'::text) > Bitmap Index Scan on tuppermc1 (cost0.00..4.47 rows25 width0) Index Cond: (upper(mc) 'c4ca4238a0b923820dcc509a6f75849b'::text) (6 rows)