Re: Composite Indexes with a function and a column

Поиск
Список
Период
Сортировка
От Alex Pires de Camargo
Тема Re: Composite Indexes with a function and a column
Дата
Msg-id CABMU1qbRX3Mvq3BXfiW60WkRmu383+ZM2rim6dMe+RTqtGDasg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Composite Indexes with a function and a column  (Christian Hammers <ch@lathspell.de>)
Ответы Re: Composite Indexes with a function and a column
Список pgsql-general
Thanks a lot!

From documentation:

"
IMMUTABLE indicates that the function cannot modify the database and always returns the same result when given the same argument values; that is, it does not do database lookups or otherwise use information not directly present in its argument list. If this option is given, any call of the function with all-constant arguments can be immediately replaced with the function value.
"

I understand that to be immutable a function should not access mutable data.

If my function access another table that I have guarantee that it will not be changed, It's safe to turn that function immutable and use in an index? I know that i'll be punished if my guarantee fails...

Regards,


On Fri, Dec 21, 2012 at 10:12 AM, Christian Hammers <ch@lathspell.de> wrote:
Hello

On Fri, 21 Dec 2012 08:46:14 -0200
Alex Pires de Camargo <acamargo@gmail.com> wrote:

> Is it possible?
>
>    Thanks!

Why not?

 devel_np=# CREATE TABLE t (i int);
 CREATE TABLE

 devel_np=# CREATE INDEX ON t (length(i::text), i);
 CREATE INDEX

bye,

-christian-



--
Alex
acamargo@gmail.com
"Por que, no mundo, os maus, tão frequentemente, sobrepujam os bons em influência?
-Pela fraqueza dos bons; Os maus são intrigantes e audaciosos, os bons são tímidos. Quando estes o quiserem, dominarão." -- Livro dos Espíritos, Q932. http://livrodosespiritos.wordpress.com/

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

Предыдущее
От: Christian Hammers
Дата:
Сообщение: Re: Composite Indexes with a function and a column
Следующее
От: Christian Hammers
Дата:
Сообщение: Re: Composite Indexes with a function and a column