pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stephan Szabo <sszabo@megazone23.bigpanda.com>
Cc: David Olbersen <DOlbersen@stbernard.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Type casting and indexes
Date: Thu, 08 May 2003 18:35:14 -0400
Message-ID: <17013.1052433314@sss.pgh.pa.us> (raw)
In-Reply-To: <20030508090101.K43697-100000@megazone23.bigpanda.com>
References: <20030508090101.K43697-100000@megazone23.bigpanda.com>

Stephan Szabo <sszabo@megazone23.bigpanda.com> writes:
> On Thu, 8 May 2003, David Olbersen wrote:
>> 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.

> IIRC, timestamp->timestamptz is not considered to give a constant value
> (ie, is not stable)

No: it is stable, but not immutable, because it depends on SET TIMEZONE.
(Our policy on those is if you change one mid-query, it's unspecified
whether the query will notice or not.)  So the query is potentially
indexable.

The problem here is that instead of seeing a constant, the planner sees
a nonconstant function invocation on the right side of '>', and so it
has to fall back to a default selectivity estimate instead of being able
to extract a reasonable estimate from pg_statistic.  The default
estimate is high enough to discourage an indexscan ...

			regards, tom lane




view thread (4+ messages)

Message-ID: <17013.1052433314@sss.pgh.pa.us>
Permalink:  ../17013.1052433314@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17013.1052433314@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, sszabo@megazone23.bigpanda.com, DOlbersen@stbernard.com
  Subject: Re: Type casting and indexes
  In-Reply-To: <17013.1052433314@sss.pgh.pa.us>
  References: <20030508090101.K43697-100000@megazone23.bigpanda.com> <17013.1052433314@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