>... > if (upper('001234') == lower('001234')) > SELECT * FROM table > WHERE id = '001234'; > else > SELECT * FROM table > WHERE upper(id) = '001234'; > >Even without the index I guess that would have saved it a lot of work.
I'm no expert, but I can't image this will be easy, because the optimizer does not know any relation between lower() and upper(). I think an index on upper(id) (create index idxname on table(upper(id))) should work well. ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED] ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html