Home > Software engineering >  create expression index on postgres timestamp
create expression index on postgres timestamp

Time:05-16

Simple table

create table x(t timestamp);

in many places i need to say

where extract(year from t) and extract(quarter from t)

can we state an expression index here ? and how

CodePudding user response:

You can use below SQL:

create index idx_cust_test on x(extract(year from t), extract(quarter from t));

The whole script can be checked on: fiddle

  • Related