Re: Timestamp conversion can't use index

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Timestamp conversion can't use index
Date: 2001-12-26 23:41:21
Message-ID: 200112262341.fBQNfLZ04681@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Based on Tom's comments and this email, I am adding this to the TODO
list:

* Add new pg_proc cachable settings to specify whether function can be
evaluated only once or once per query

---------------------------------------------------------------------------

> > Someone reported to me that they can't get their queries to use indexes.
> > It turns out this is because timestamp() has pg_proc.proiscachable set
> > to false in many cases. Date() also has this in some cases.
>
> Please let me add a reference to this email from Tom Lane:
>
> http://fts.postgresql.org/db/mw/msg.html?mid=1041918
>
> It specifically states:
>
> [More complete] reasonable [cachable] definitions would be:
>
> 1. noncachable: must be called every time; not guaranteed to return same
> result for same parameters even within a query. random(), timeofday(),
> nextval() are examples.
>
> 2. fully cachable: function guarantees same result for same parameters
> no matter when invoked. This setting allows a call with constant
> parameters to be constant-folded on sight.
>
> 3. query cachable: function guarantees same result for same parameters
> within a single query, or more precisely within a single
> CommandCounterIncrement interval. This corresponds to the actual
> behavior of functions that execute SELECTs, and it's sufficiently strong
> to allow the function result to be used in an indexscan, which is what
> we really care about.
>
> Item #2 clearly mentions constant folding, I assume by the optimizer.
> What has me confused is why constant folding is needed to perform index
> lookups. Can't the executor call the function and then do the index
> lookup? Is this just a failing in our executor? Is there a reason
> #1-type noncachable functions can't use indexes? Is the timezone
> related here?
>
> --
> Bruce Momjian | http://candle.pha.pa.us
> pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
> + If your life is a hard drive, | 830 Blythe Avenue
> + Christ can be your backup. | Drexel Hill, Pennsylvania 19026

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-12-26 23:53:49 Re: Timestamp conversion can't use index
Previous Message Tom Lane 2001-12-26 17:35:42 Re: Timestamp conversion can't use index