pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joshua D. Drake <jd@commandprompt.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Ray <ray_siu@ge-ts.com.hk>
Cc: pgsql-performance@postgresql.org
Subject: Re: create index with substr function
Date: Wed, 20 Oct 2004 23:13:32 -0700
Message-ID: <4177538C.7010900@commandprompt.com> (raw)
In-Reply-To: <10774.1098327554@sss.pgh.pa.us>
References: <069201c4b715$34851670$0f6010ac@raysiu>
	<10774.1098327554@sss.pgh.pa.us>

Tom Lane wrote:

>"Ray" <ray_siu@ge-ts.com.hk> writes:
>  
>
>>CREATE INDEX idx_doc_substr_doc_urn ON doc USING btree (SUBSTR(doc_urn,10));
>>ERROR:  parser: parse error at or near "10" at character 68
>>    
>>
>
>This will work in 7.4, but not older releases.
>
>  
>
Can't you just use a SQL function that calls the substr function? I have 
done that with date functions before
like:

CREATE OR REPLACE FUNCTION get_month(text) returns double precision AS '
   SELECT date_part('month',$1);
' LANGUAGE 'SQL' IMMUTABLE;

CREATE INDEX get_month_idx on foo(get_month(date_field));

Or in this case:

CREATE OR REPLACE FUNCTION sub_text(text) returns text AS '
      SELECT SUBSTR($1,10) from foo;
' LANGUAGE 'SQL' IMMUTABLE;

CREATE INDEX sub_text_idx ON foo(sub_text(doc_urn));

This works on 7.3.6???

Sincerely,

Joshua D. Drake




>			regards, tom lane
>
>---------------------------(end of broadcast)---------------------------
>TIP 7: don't forget to increase your free space map settings
>  
>


-- 
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL

view thread (8+ messages)  latest in thread

Message-ID: <4177538C.7010900@commandprompt.com>
Permalink:  ../4177538C.7010900@commandprompt.com/
Also on:    postgresql.org/message-id/4177538C.7010900@commandprompt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: jd@commandprompt.com, tgl@sss.pgh.pa.us, ray_siu@ge-ts.com.hk
  Subject: Re: create index with substr function
  In-Reply-To: <4177538C.7010900@commandprompt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox