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