col1 ILIKE 'foo%' not behaving the same as lower(col1) LIKE 'foo%'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux