X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7757D32B1E5 for ; Thu, 21 Oct 2004 06:12:20 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 61307-02 for ; Thu, 21 Oct 2004 05:12:16 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 4C3FB32B18C for ; Thu, 21 Oct 2004 06:11:39 +0100 (BST) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr4.postgresql.org (Postfix) with ESMTP id 857515AF563 for ; Thu, 21 Oct 2004 03:05:30 +0000 (GMT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 2B4F235B1F; Wed, 20 Oct 2004 19:57:54 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 29D1C35AF8; Wed, 20 Oct 2004 19:57:54 -0700 (PDT) Date: Wed, 20 Oct 2004 19:57:54 -0700 (PDT) From: Stephan Szabo To: Ray Cc: pgsql-performance@postgresql.org Subject: Re: create index with substr function In-Reply-To: <069201c4b715$34851670$0f6010ac@raysiu> Message-ID: <20041020195604.T32588@megazone.bigpanda.com> References: <069201c4b715$34851670$0f6010ac@raysiu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/335 X-Sequence-Number: 8811 On Thu, 21 Oct 2004, Ray wrote: > Hi All, > > I have a table in my postgres: > Table: doc > Column | Type | Modifiers > ---------------+-----------------------------+----------- > doc_id | bigint | not null > comp_grp_id | bigint | not null > doc_type | character varying(10)| not null > doc_urn | character varying(20)| not null > > I want to create an index on doc_urn column with using substr function like this: > CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10)); > > but there is an error: > > ERROR: parser: parse error at or near "10" at character 68 > > what's wrong for this SQL? As I have found some reference on the > internet, I can't find anything wrong in this SQL. What version are you using? If you're using anything previous to 7.4 then the above definately won't work and the only work around I know of is to make another function which takes only the column argument and calls substr with the 10 constant.