Hi,
I find a way to create index, I create a function returns the 'id' field of udt info, then I create index based on this function.
e.g
create type info as (id int, name text);
creat table test (id int, i info);
create or replace function getID(i info) returns int as
language sql;
create index infoindex on test (getID(i));
I want to use this index, but after I insert lots of data to the table 'test' and run 'select * from test where
i.id=5', it still use 'seqscan', not 'index scan'. How can I verify the index is build correctly?
e.g.
insert into test values (generate_series(1, 3000000), (1, 'hi')::info);
explain select * from test where
i.id=1;
the result is : seqscan