Re: INDEXng date_trunc ...

Поиск
Список
Период
Сортировка
От Brent Verner
Тема Re: INDEXng date_trunc ...
Дата
Msg-id 20011122102905.A34094@rcfile.org
обсуждение исходный текст
Ответ на INDEXng date_trunc ...  ("Marc G. Fournier" <scrappy@hub.org>)
Ответы Re: INDEXng date_trunc ...  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
On 22 Nov 2001 at 09:41 (-0500), Marc G. Fournier wrote:
| 
| In v7.2, how does one index a function?
| 
| CREATE INDEX hourly_stats_day
|           ON hourly_stats
|        USING btree ( DATE_TRUNC('day',runtime) ) ;
| 
| Gives me:
| 
| ERROR:  parser: parse error at or near "'"

from $htmldocs/indexes-functional.html:
 "The function in the index definition can take more than one  argument, but they must be table columns, not constants.
Functional indexes are always single-column (namely, the  function result) even if the function uses more than one
inputfield; there cannot be multicolumn indexes that  contain function calls.
 
   Tip: The restrictions mentioned in the previous paragraph       can easily be worked around by defining a custom
 function to use in the index definition that computes      any desired result internally."
 

so...

create table test( id serial, tid timestamp default now() );

create function date_part_day(timestamp) returns float8 as ' select date_part(''day'',$1);
' language SQL with(iscachable);
create index ix_test_tid on test( date_part_day(tid) );


I have /no clue whatsoever/ how well that will work.  Now, I'm curious
why we can't take a constant as an argument to an indexed function... 

hth. brent

-- 
"...curiousity and the cat."
Why do /I/ have to be that cat?                        -- dbv


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

Предыдущее
От: "Henshall, Stuart - WCP"
Дата:
Сообщение: Re: ldap support
Следующее
От: frbn@efbs-seafrigo.fr
Дата:
Сообщение: Re: SELECT * FROM t where p or q;