Re: Partial index with regexp not working

From: "Phoenix Kiula" <phoenix(dot)kiula(at)gmail(dot)com>
To: "Richard Huxton" <dev(at)archonet(dot)com>, "Richard Broersma Jr" <rabroersma(at)yahoo(dot)com>
Cc: "Postgres General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Partial index with regexp not working
Date: 2007-09-12 12:31:18
Message-ID: e373d31e0709120531p64fcd60cnde21f8a854039573@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 11/09/2007, Phoenix Kiula <phoenix(dot)kiula(at)gmail(dot)com> wrote:
>
> The suggestion in this thread that a regex index will come into play
> only when the WHERE condition specifically mentions it was indeed the
> key for me.

Ok, I've hit a snag about this index. I think it's to do with how my
regex is structured. Basically this column can have either IP
addresses, or alphanumeric user IDs. If it is not an IP address, it is
a registered user ID. What is the best way of ascertaining that a
column value is *not* an IP address?

I tried this:

select * from trader where trader_id !~ '[0-9]+\.[0-9]+\.[0-9]+\.';

And this works, but I wonder if a partial index on a negative
condition ("!~") will be slower than a positive condition?

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Asko Oja 2007-09-12 12:32:04 Re: Sthange things happen: SkyTools pgbouncer is NOT a balancer
Previous Message David 2007-09-12 11:41:35 Re: pgpool II question