Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: How to influence the planner



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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group