Re: Partial index with regexp not working

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

Phoenix Kiula wrote:
>
> 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?

To be honest, I'd probably just have a separate column "uid_type", set
it when creating the user and then just have a partial index WHERE
uid_type='IP'

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Asko Oja 2007-09-12 12:46:25 Re: Scalability Design Questions
Previous Message Richard Huxton 2007-09-12 12:33:24 Re: Database/Table Design for Global Country Statistics