Re: BUG #1325: like error - Mailing list pgsql-bugs

From Stephan Szabo
Subject Re: BUG #1325: like error
Date
Msg-id 20041118061342.D72782@megazone.bigpanda.com
Whole thread Raw
In response to BUG #1325: like error  ("PostgreSQL Bugs List" <pgsql-bugs@postgresql.org>)
List pgsql-bugs
On Thu, 18 Nov 2004, PostgreSQL Bugs List wrote:

> select * from tbinvoicerows
> where invoicecd = 'FLOCAA00000025'
>
> result in 0 seconde with 2 records   NO BUG
>
> select * from tbinvoicerows
> where invoicecd like '%FLOCAA00000025%'
>
> result in 40 secondes with 2 records   NO BUG
>
> select * from tbinvoicerows
> where invoicecd like 'FLOCAA00000025%'
>
> result in 40 secondes with 2 records  BUG
> Bug : the result is good but I expect a result faster as the first select
> (like in mssql 7)

To add to the reply already given...

If you're running in "C" locale, the last should be able to use a normal
index on invoicecd.  However, since that didn't appear to happen, either
it's estimating a large number of rows which is unlikely or you are in
some other locale.

For other locales, you may want a pattern_ops index, which would be
something like:
 create index foo on tbinvoicerows(invoicecd varchar_pattern_ops).

pgsql-bugs by date:

Previous
From: Richard Huxton
Date:
Subject: Re: BUG #1325: like error
Next
From: Cao Duy
Date:
Subject: column doesnt exist?