Search code examples
postgresqlpartial-index

Can I create a partial index as shown in below?


Assume there is a table with 5 columns (id ,first_name (text),last_name(text), product_name(text) and available(boolean)).

CREATE INDEX IF NOT EXISTS "idx-firstname-lower + product_name" 
  ON persons (LOWER(first_name), product_name) WHERE available;

Solution

  • Yes, you can create that index, although I would reconsider the index name. Use a standard conforming name like mytab_lower_firstname_productname_idx.