Re: Conversion of string to int using digits at beginning

From: "Andrus" <kobruleht2(at)hot(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Conversion of string to int using digits at beginning
Date: 2008-11-19 10:50:23
Message-ID: gg0r1m$25ru$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sam,

> Maybe something like:
>
> SELECT MAX(nullif(regexp_replace(test, '^([0-9]*).*$', E'\\1'),'')::INT);

Thank you.
This seems to work but is bit slow.

How to speed it up ?

Should I create index

CREATE INDEX test ON test ( nullif(regexp_replace(test, '^([0-9]*).*$',
E'\\1'),'')::INT );

?

Andrus.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sabin Coanda 2008-11-19 10:57:37 COPY problem on -- strings
Previous Message Raymond O'Donnell 2008-11-19 10:05:04 Re: How to list only my functions and their content?