col1 ILIKE 'foo%' not behaving the same as lower(col1) LIKE 'foo%' - Mailing list pgsql-performance

From milos d
Subject col1 ILIKE 'foo%' not behaving the same as lower(col1) LIKE 'foo%'
Date
Msg-id COL115-W810E7D489AB499923CA917D5BB0@phx.gbl
Whole thread Raw
Responses Re: col1 ILIKE 'foo%' not behaving the same as lower(col1) LIKE 'foo%'
List pgsql-performance
Hello,

I have a table 'foo_bar' with a column 'col1' defined as 'col1 varchar(512)'. This column is indexed using an expression index defined as

CREATE INDEX ix_foo_bar_by_col1 ON foo_bar(lower(col1) col1 varchar_pattern_ops)

The problem is when I try matching using ILIKE, (col1 ILIKE 'foo%')  PostgreSQL does not use an index scan but a Seq scan of the whole table, but when I try (lower(col1) LIKE 'foo%') PostgreSQL uses an index scan.

Could this be a bug with ILIKE or am I missing something?

The table has ~ 4 million rows.
PostgreSQL 8.3.5 on Windows Vista, non C locale, DB encoding is LATIN1.

Thank you in advance,
Milos.

Combine your email accounts here! Want to marry your mail?

pgsql-performance by date:

Previous
From: Guillaume Cottenceau
Date:
Subject: Re: scheduling autovacuum at lean hours only.
Next
From: Richard Huxton
Date:
Subject: Re: col1 ILIKE 'foo%' not behaving the same as lower(col1) LIKE 'foo%'