From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | hubert depesz lubaczewski <depesz(at)depesz(dot)pl> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: how do functional indices work? |
Date: | 2001-09-04 14:33:20 |
Message-ID: | 26246.999614000@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
hubert depesz lubaczewski <depesz(at)depesz(dot)pl> writes:
> let's assume i have table users which is (id int4, person_id int4) - pkey'ed
> on id with index on person_id.
> next i have table people (id int4, fullname text) with pkey on id.
> there is a foreign key between the two tables on users.person_id => people.id.
> now i wrote a function, which given user id returns it's person's name. quite
> simple function.
> not i want to make a index:
> create index test on users (myMagicalFunction(id));
> this of course works,
No, it doesn't. A functional index using a function that depends on any
data other than its explicitly passed parameters is a horribly bad idea.
It WILL fail --- nastily --- as soon as you change the other table.
To help catch this, 7.2 will not allow you to build functional indexes
on functions that are not marked "iscachable".
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Doug McNaught | 2001-09-04 14:35:07 | Re: SHOW |
Previous Message | Jerry Asher | 2001-09-04 14:33:15 | Re: upgrade from 7.1.2 to 7.1.3 and uh, where are my |