Re: How to influence the planner
| От | Tom Lane |
|---|---|
| Тема | Re: How to influence the planner |
| Дата | |
| Msg-id | 2170.1188597013@sss.pgh.pa.us обсуждение |
| Ответ на | Re: How to influence the planner (Michael Glaesemann <grzm@seespotcode.net>) |
| Список | pgsql-sql |
Michael Glaesemann <grzm@seespotcode.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 toselect * 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
В списке pgsql-sql по дате отправления: