[ADMIN] creating index with a cast statement in the predicate

Поиск
Список
Период
Сортировка
От Mark Steben
Тема [ADMIN] creating index with a cast statement in the predicate
Дата
Msg-id CADyzmyxcrg-U2TECTDyj9gk=c21RwMpJf2HGk+fM3m3-bOyiZQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: [ADMIN] creating index with a cast statement in the predicate
Список pgsql-admin
Good afternoon

I am currently running postgres 9.4.8.

    I would like to create an index on a column named value: defined as varchar(255)
Values in this column can be many, including both dates and non-dates.
The developers run a query that first uses a regular expression to filter non-dates out
then, ANDS it with the following  
 and cast(value as date) >= date_trunc('MONTH', current_date) - interval ' 2 Month '
    When I attempt to create an index using this statement in the predicate, I get the error that states that functions in an index predicate must be marked as Immutable.
Our internal functions date_trunc (all 3) and date are all already defined as immutable.
I can create an index with the regular expression as the predicate but not the cast statement comparison.

   Here is the regular expression index I constructed:
  "primets_custattr_small_regexp" btree (value) WHERE value::text ~ '([0-9][0-9][0-9][0-9])-(0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01])|([0-9][0-9][0-9][0-9])-(0[469]|11])-(0[1-9]|[12][0-9]|30)|([0-9][0-9][0248][048]|[0-9][0-9][13579][26])-(02)-(0[1-9]|1[0-9]|2[0-9])|([0-9][0-9][0248][1235679]|[0-9][0-9][13579][01345789])-(02)-(0[1-9]|1[0-9]|2[0-8])'::text

I would appreciate any insight here.  Thank you

 


--
Mark Steben
 Database Administrator
@utoRevenue | Autobase 
  CRM division of Dominion Dealer Solutions 
95D Ashley Ave.
West Springfield, MA 01089

t: 413.327-3045
f: 413.383-9567

www.fb.com/DominionDealerSolutions
www.twitter.com/DominionDealer
 www.drivedominion.com





В списке pgsql-admin по дате отправления:

Предыдущее
От: Scott Whitney
Дата:
Сообщение: Re: [ADMIN] pgdg96 repo with centos 7.x - server starts only onloopback
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [ADMIN] creating index with a cast statement in the predicate