Functional indices with const params.

Started by Denis Perchineover 25 years ago2 messagesgeneral
Jump to latest
#1Denis Perchine
dyp@perchine.com

Hello,

is it possible to create functional indices with constant params?

I tried to do
create index ix_s_m on stats(date_part('month', sent_date));

And get
ERROR: parser: parse error at or near "'"

If it is not possible is there any workarounds for this?

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Denis Perchine (#1)
Re: Functional indices with const params.

Denis Perchine <dyp@perchine.com> writes:

is it possible to create functional indices with constant params?

create index ix_s_m on stats(date_part('month', sent_date));

No.

If it is not possible is there any workarounds for this?

Sure: make your own function that does what you want with no extra
parameters. I don't think an SQL function works as an index function
right now (I may be able to fix that for 7.1, but no promises), but a
plpgsql (or pl-anything) function should work.

regards, tom lane