Re: 7.4 Wishlist - Mailing list pgsql-hackers

From Stephan Szabo
Subject Re: 7.4 Wishlist
Date
Msg-id 20021202212110.X64892-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: 7.4 Wishlist  ("Magnus Naeslund(f)" <mag@fbab.net>)
List pgsql-hackers
On Tue, 3 Dec 2002, Magnus Naeslund(f) wrote:

> Now convert this query so that it only evaluates the date_part thing
> ONCE:

That's not a good idea as long as t.stamp varies from row to row. ;)
Perhaps once per row, maybe... :)

> select t.id, date_part('days',now()-t.stamp) from table_name t where
> date_part('days',now()-t.stamp) > 20;

Potentially I think something like this would do it:
select t.id, t.foo from (select id, date_part('days', now()-stamp)
as foo from table_name except select null, null) as t where foo>20;

It's not really an optimization given the required except, but if there
was some way to tell the system not to push clauses down into a subselect
you wouldn't even need that.



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: 7.4 Wishlist
Next
From: "Magnus Naeslund(f)"
Date:
Subject: Re: 7.4 Wishlist