Re: [GENERAL] indexed regex select optimisation missing?

From: Stuart Woolford <stuartw(at)newmail(dot)net>
To: "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] indexed regex select optimisation missing?
Date: 1999-11-04 23:59:03
Message-ID: 99110513024300.05794@test.macmillan.co.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Fri, 05 Nov 1999, Ross J. Reedstrom wrote:
> Ah, your description just tripped a memory for me from the hackers list:
>
> The behavior you describe has to do with the implementation of using an
> index for regex matching, in the presence of the USE_LOCALE configuration
> option.
>
> Internally, the condition: WHERE word~'^alongword' is converted in the
> parser(!) to:
>
> WHERE word >= 'alongword' AND word < 'alongword\377'
>
> since the index needs inequalities to be used, not matches. Now, the
> problem is the hack of tacking an octal \377 on the string to create
> the lexagraphically 'just bigger' value assumes ASCI sort order. If
> USE_LOCALE is defined, this is dropped, since we don't have a good fix
> yet, and slow correct behavior is better than fast, incorrect behavior.

just to add to my previous reply, the 'hack' I am using now is:

select key from inv_word_i where word>='window' and word<'window\372'

which matches very nearly everything in my database (actually, I limit data to
printable characters, so it should be safe), and words with my normal queries
(which are actually Zope queries, and therefore changing the actual search word
is a little non-trivial)

anyway, just a quick hack that helps performance by several orders of magnitude
if you have locale enabled (ie: are using the standard RPMs)
BTW, I assume that my databases will need requilding if I compile up a
non-locale aware version, which presents a problem currently :(

------------------------------------------------------------
Stuart Woolford,
stuartw(at)newmail(dot)net Unix Consultant.
Software Developer.
Supra Club of New Zealand.
------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Fedde 1999-11-05 00:20:18 subscribe pgsql-general
Previous Message Stuart Woolford 1999-11-04 23:09:19 Re: [GENERAL] indexed regex select optimisation missing?

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 1999-11-05 00:35:50 Re: [HACKERS] Path-length follies
Previous Message Don Baccus 1999-11-04 23:34:35 Re: [HACKERS] New version of psql