Re: creating an index on a function

Поиск
Список
Период
Сортировка
От Brent Verner
Тема Re: creating an index on a function
Дата
Msg-id 20020215154252.GA78209@rcfile.org
обсуждение исходный текст
Ответ на creating an index on a function  ("Nick Fankhauser" <nickf@ontko.com>)
Список pgsql-sql
[2002-02-15 09:26] Nick Fankhauser said:
| Good Morning everyone!
| 
| I just tried to create an index on a function with no success. My syntax
| seems to match the syntax shown in the docs for Create Index, but I get an
| error. Any thoughts would be appreciated. Here is my attempt-
| 
| First, I did a select to make sure I had the function syntax correct, and
| then tried to create the index:
| 
| 
| staging=# select count(*) from event where
| date_trunc('day',event_date_time)='07/27/2001';
|  count
| -------
|     27
| (1 row)
| 
| staging=#
| staging=# create index event_day on
| event(date_trunc('day',event_date_time));

You cannot create an index on a function with constant parameters.
This limitation may be removed in a future version, but for now
you have to create a wrapper function that doesn't require the
constant parameter
 CREATE FUNCTION date_trunc_day(TIMESTAMP) RETURNS TIMESTAMP AS '    SELECT date_trunc(''day'',$1); ' LANGUAGE 'sql';

then use this to create your function index.   create index event_day on    event(date_trunc_day(event_date_time));

hth. brent

-- 
"Develop your talent, man, and leave the world something. Records are 
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman


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

Предыдущее
От: "Nick Fankhauser"
Дата:
Сообщение: creating an index on a function
Следующее
От: Tom Lane
Дата:
Сообщение: Re: creating an index on a function