From: | Itai Zukerman <zukerman(at)math-hat(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Indices and time spans |
Date: | 2000-07-31 16:07:42 |
Message-ID: | 878zui1dwx.fsf@matt.w80.math-hat.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Sandis | 2000-07-31 19:48:16 | Simple concatenation in select query |
Previous Message | Jerome Raupach | 2000-07-31 15:43:56 | result in a variable? |