From: | george young <gry(at)ll(dot)mit(dot)edu> |
---|---|
To: | "Ray" <ray_siu(at)ge-ts(dot)com(dot)hk> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: create index with substr function |
Date: | 2004-10-21 14:22:37 |
Message-ID: | 20041021102237.5ae1d14e.gry@ll.mit.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
As previously suggested by Stephan Szabo, you need to create a helper
function, e.g.:
create or replace function after9(text)returns text language plpgsql immutable as '
begin
return substr($1, 10);
end;
';
You may need the "immutable" specification is to allow the
function's use in an index.
Then use this function in the index creation:
CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (after9(doc_urn));
I think that should do it.
-- George
>
On Thu, 21 Oct 2004 11:37:26 +0800
"Ray" <ray_siu(at)ge-ts(dot)com(dot)hk> threw this fish to the penguins:
> sorry it doesn't works, as my postgres is 7.3 not 7.4. any other alternative
> solution for version after 7.4??
>
> Thank
> Ray : )
>
> ----- Original Message -----
> From: "Rosser Schwarz" <rosser(dot)schwarz(at)gmail(dot)com>
> To: "Ray" <ray_siu(at)ge-ts(dot)com(dot)hk>
> Cc: <pgsql-performance(at)postgresql(dot)org>
> Sent: Thursday, October 21, 2004 11:34 AM
> Subject: Re: [PERFORM] create index with substr function
>
>
> > while you weren't looking, Ray wrote:
> >
> > > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree
> (SUBSTR(doc_urn,10));
> >
> > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree
> ((SUBSTR(doc_urn,10)));
> >
> > You need an additional set of parens around the SUBSTR() call.
> >
> > /rls
> >
> > --
> > :wq
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
--
"Are the gods not just?" "Oh no, child.
What would become of us if they were?" (CSL)
From | Date | Subject | |
---|---|---|---|
Next Message | Victor Ciurus | 2004-10-21 14:34:17 | Simple machine-killing query! |
Previous Message | Tom Lane | 2004-10-21 14:20:55 | Re: Anything to be gained from a 'Postgres Filesystem'? |