Problem with index using regular expression

From: Håvard Wahl Kongsgård <haavard(dot)kongsgaard(at)gmail(dot)com>
To: psycopg(at)postgresql(dot)org
Subject: Problem with index using regular expression
Date: 2011-06-06 06:32:41
Message-ID: BANLkTi=2jJ8rAp-92==mzxpSABdHZ8vv+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

Hi, with psycopg 2-2.4.1 I have some issue with incorrect use of indexes
using regular expression.
I my case I have create on index on the surname of users.
CREATE INDEX income_surname ON income(substring(income.name from
E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$'))

then used
SELECT Distinct On (nodes.id) nodes.ID from nodes inner join income on
substring(nodes.name from E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$') = substring(
income.name from E'\\w.*\\s(\\w.*)$|\\w+\\s(\\w.*)$')

with psql the index works fine, but with psycopg I don't think it's used at
all. The index substring has to be identical with the substring in
the query. Are there some encoding issues with psycopg?

--
Håvard Wahl Kongsgård

http://havard.security-review.net/

Responses

Browse psycopg by date

  From Date Subject
Next Message Federico Di Gregorio 2011-06-06 06:58:00 Re: Problem with index using regular expression
Previous Message Daniele Varrazzo 2011-06-04 21:54:28 Re: Installing via pip under Win7 + virtualenv + VC++2008