From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
Cc: | Richard Ray <rray(at)mstc(dot)state(dot)ms(dot)us>, pgsql-sql(at)postgresql(dot)org |
Subject: | Re: How to influence the planner |
Date: | 2007-08-31 21:50:13 |
Message-ID: | 2170.1188597013@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Michael Glaesemann <grzm(at)seespotcode(dot)net> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Ray | 2007-09-01 00:03:39 | Re: How to influence the planner |
Previous Message | Michael Glaesemann | 2007-08-31 21:38:20 | Re: How to influence the planner |