* Tom Lane <tgl@sss.pgh.pa.us> [010518 22:39]:
> Larry Rosenman <ler@lerctr.org> writes:
> > CREATE FUNCTION "nowminus" (interval) RETURNS timestamp with time zone AS 'SELECT now() - $1;' LANGUAGE 'sql';
>
> Right idea, but you need to mark it iscachable.
Aha:
Same query, with nowminus marked iscachable:
NOTICE: QUERY PLAN:
Sort (cost=513.69..513.69 rows=447 width=120) -> Index Scan using start_index, end_index on attack_db
(cost=0.00..494.01rows=447 width=120) SubPlan -> Seq Scan on exempt_ips (cost=0.00..1.04 rows=4
width=12) -> Seq Scan on exempt_ips (cost=0.00..1.04 rows=4 width=12)
EXPLAIN
>
> regards, tom lane
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749