Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
| От | Tom Lane |
|---|---|
| Тема | Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W) |
| Дата | |
| Msg-id | 17556.1066844690@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Functional index problems. (Was: Many joins: monthly summaries S-L--O--W) (Michael Glaesmann <grzm@myrealbox.com>) |
| Ответы |
Re: Functional index problems. (Was: Many joins: monthly summaries S-L--O--W)
|
| Список | pgsql-novice |
Michael Glaesmann <grzm@myrealbox.com> writes:
> Searching for ways to improve performance, I tried to create a index on
> the extract function, but for some reason I couldn't get it to work.
> Following the documentation for CREATE INDEX and EXTRACT, I tried
> CREATE INDEX dborders_extract_month_idx ON dborders (EXTRACT(MONTH from
> date));
> ERROR: parser: parse error at or near "(" at character 61
You can't do that in pre-7.4 releases; the syntax of a functional index
can only be "ON table (func(col1,col2,...))" --- that is, a simple,
standard-notation function applied to one or more columns of the table.
So to do this, you'd need to create an intermediate function along
the lines of "month_trunc(date)"; and you'd have to use it in your
queries as well as in the index definition.
7.4 is more flexible though --- it will take the above as long as you
put an extra set of parentheses in there...
regards, tom lane
В списке pgsql-novice по дате отправления: