Re: Index on a function(field)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Index on a function(field)
Дата
Msg-id 6656.989610319@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Index on a function(field)  (Gabriel Fernandez <gabi@unica.edu>)
Список pgsql-general
Gabriel Fernandez <gabi@unica.edu> writes:
> Is it possible to create an index using a function(field) sintaxis ?

Yes, but *only* on a function of one or more raw fields.

> CREATE  INDEX "i1_cdu" on "cdu" using btree ( substr(cdu_code,1,1)
> "varchar_ops" );

This doesn't work because you have some constants floating around in the
mix.

In theory you can work around this by creating a custom function, say
firstchar(varchar), that does "substr(x,1,1)", and then writing

CREATE  INDEX "i1_cdu" on "cdu" using btree ( firstchar(cdu_code) );

It's kind of a pain though...

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: name truncation problem in 7.0.0
Следующее
От: larry a price
Дата:
Сообщение: Re: Nu-B Question