From: Itai Zukerman <zukerman@math-hat.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: Indices and time spans
Date: 31 Jul 2000 12:07:42 -0400
Message-ID: <878zui1dwx.fsf@matt.w80.math-hat.com> (raw)
References: <87g0oqbej1.fsf@matt.w80.math-hat.com>
<9449.965054960@sss.pgh.pa.us>
> You need to recast the clause as something like
>
> WHERE posted >= (CURRENT_TIMESTAMP - '5 minutes'::TIMESPAN)
>
> Then you still have the problem of persuading Postgres that it should
> treat the right side of this as a constant and not something to
> re-evaluate at each row. In 7.0 and later it's possible to do that
> with creative use of a user-defined function marked "iscachable"
> (for details see the archives for the last time this question came up,
> a few months back).
That did the trick, thanks!
Just for reference:
CREATE FUNCTION time_machine ( TIMESPAN )
RETURNS TIMESTAMP
AS 'SELECT CURRENT_TIMESTAMP - $1'
LANGUAGE 'sql'
WITH (iscachable);
seems to work. Perhaps it's more complicated than that, though?
-itai
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-sql@postgresql.org
Cc: zukerman@math-hat.com, tgl@sss.pgh.pa.us
Subject: Re: Indices and time spans
In-Reply-To: <878zui1dwx.fsf@matt.w80.math-hat.com>
References: <87g0oqbej1.fsf@matt.w80.math-hat.com> <9449.965054960@sss.pgh.pa.us> <878zui1dwx.fsf@matt.w80.math-hat.com>
* 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