pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Olbersen <DOlbersen@stbernard.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Type casting and indexes
Date: Thu, 08 May 2003 12:25:07 -0400
Message-ID: <20978.1052411107@sss.pgh.pa.us> (raw)
In-Reply-To: <E7E213858379814A9AE48CA6754F5ECB0D6DDE@mail01.stbernard.com>
References: <E7E213858379814A9AE48CA6754F5ECB0D6DDE@mail01.stbernard.com>

"David Olbersen" <DOlbersen@stbernard.com> writes:
> So it seems that the type conversion is killing the use of the index, even though the type conversion has to happen for the condition to be tested.

Seems like I just answered this yesterday ;-)

Note the difference in the number of estimated rows in the two explains.
The reason is that the timestamptz conversion is not a constant and so
the planner can't get a good estimate of the number of rows that will
satisfy it.  (And the reason it's not a constant is that it depends on
SET TIMEZONE.)

Bottom line: declare the constant correctly.  Or at least don't
gratuitously cast it to the wrong thing.

			regards, tom lane




view thread (4+ messages)  latest in thread

Message-ID: <20978.1052411107@sss.pgh.pa.us>
Permalink:  ../20978.1052411107@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20978.1052411107@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, DOlbersen@stbernard.com
  Subject: Re: Type casting and indexes
  In-Reply-To: <20978.1052411107@sss.pgh.pa.us>
  References: <E7E213858379814A9AE48CA6754F5ECB0D6DDE@mail01.stbernard.com> <20978.1052411107@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