Michael Glaesemann <[EMAIL PROTECTED]> writes: > On Aug 31, 2007, at 16:07 , Richard Ray wrote: >>> If length(bar) = 0 is a common operation on this table, you might >>> consider using an expression index on t1: >> >>> create index t1_length_bar_idx on t1 (length(bar)); >> >> This is a one time procedure to fix some data but I've had this >> problem before
Actually, I just noticed that the OP does have an index on bar, which means (assuming it's a string data type) that this query is equivalent to select * from t1 where bar = '' which would be a far preferable way to do it because that condition can use the index. The Postgres planner is fairly data-type-agnostic and does not have the knowledge that these are equivalent queries, so you can't expect it to make that substitution for you. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org