pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Glaesemann <grzm@seespotcode.net>
Cc: Richard Ray <rray@mstc.state.ms.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to influence the planner
Date: Fri, 31 Aug 2007 17:50:13 -0400
Message-ID: <2170.1188597013@sss.pgh.pa.us> (raw)
In-Reply-To: <F01EA480-832E-44E4-956E-1E740C48F622@seespotcode.net>
References: <Pine.LNX.4.64.0708311116000.17749@rray.drdc.mstc.ms.gov>
	<373D2F52-E9CD-485A-9BF1-B019349FA5EC@seespotcode.net>
	<Pine.LNX.4.64.0708311557140.17749@rray.drdc.mstc.ms.gov>
	<F01EA480-832E-44E4-956E-1E740C48F622@seespotcode.net>

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 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



view thread (10+ messages)  latest in thread

Message-ID: <2170.1188597013@sss.pgh.pa.us>
Permalink:  ../2170.1188597013@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2170.1188597013@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, grzm@seespotcode.net, rray@mstc.state.ms.us
  Subject: Re: How to influence the planner
  In-Reply-To: <2170.1188597013@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox