Re: passing constant parameters to functional indices

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Abhijit Menon-Sen <ams(at)wiw(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: passing constant parameters to functional indices
Date: 2003-05-14 16:31:14
Message-ID: 24959.1052929874@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Abhijit Menon-Sen <ams(at)wiw(dot)org> writes:
> I'd like to add support for specifying constant parameters when creating
> a functional index, e.g. create index foo on bar (substr(baz, 1, 32));
> Is this a good idea?

I think you are thinking of it the wrong way. Rather than restricting
yourself to a single function call, replace the entire "functional
index" facility with an "expressional index" facility --- ie you can
index on the result of any scalar expression, of which a function call
is just a special case. Since you'll have to change the contents of
pg_index anyway, you may as well implement the more general solution.

The mechanisms associated with CHECK constraints already do everything
needed for this; it's just that they only allow expressions delivering
boolean results. So you shouldn't have a great deal of trouble finding
prototype code to follow.

This has been discussed before. Try searching the archives for
"expressional index" to see if there's anything useful.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message ohp 2003-05-14 16:57:31 DNS problem,
Previous Message Zeugswetter Andreas SB SD 2003-05-14 16:27:49 Re: Client encoding conversion for binary data (was Re: GUC and postgresql.conf docs)