Skip site navigation (1) Skip section navigation (2)

Re: create index with substr function

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Ray <ray_siu(at)ge-ts(dot)com(dot)hk>, pgsql-performance(at)postgresql(dot)org
Subject: Re: create index with substr function
Date: 2004-10-21 06:13:32
Message-ID: 4177538C.7010900@commandprompt.com (view raw or flat)
Thread:
Lists: pgsql-performance
Tom Lane wrote:

>"Ray" <ray_siu(at)ge-ts(dot)com(dot)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(at)commandprompt(dot)com - http://www.commandprompt.com
PostgreSQL Replicator -- production quality replication for PostgreSQL

In response to

pgsql-performance by date

Next:From: Matt ClarkDate: 2004-10-21 07:58:01
Subject: Anything to be gained from a 'Postgres Filesystem'?
Previous:From: Manfred SpraulDate: 2004-10-21 05:45:53
Subject: Re: futex results with dbt-3

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group