Re: Regex query not using index

From: Chris <dmagick(at)gmail(dot)com>
To: Postgres User <postgres(dot)developer(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Regex query not using index
Date: 2008-02-20 05:34:22
Message-ID: 47BBBBDE.1090901@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Postgres User wrote:
> Yes that works, but the whole point of the exercise is replace many OR
> statements with 1 regex expression. So it's not what I'm looking for.

Why do you want it done this way?

You can build an array of strings to check and use an in clause.

Using php :

$checks = array('AA', 'BA');

$query = "select * from table where name in ('" . implode("','",
$checks) . "')";

and it should use an index (up to a point anyway).

--
Postgresql & php tutorials
http://www.designmagick.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-02-20 05:39:38 Re:
Previous Message Postgres User 2008-02-20 05:29:50 Re: Regex query not using index