Re: 7.4 Wishlist

From: "Magnus Naeslund(f)" <mag(at)fbab(dot)net>
To: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: 7.4 Wishlist
Date: 2002-12-03 05:14:13
Message-ID: 0a1a01c29a8a$d1da6370$f80c0a0a@mnd
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-advocacy pgsql-general pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> Magnus Naeslund(f) wrote:
>>> select id, sum(sum_col)||'/'||count(*) from table_name
>>> group by id;
>>>
>>> or
>>>
>>> select table_name.id, sum(sum_col)||'/'||t2.count from table_name,
>>> (select id, count(*) as count from table_name group by id) as t2
>>> where table_name.id=t2.id group by table_name.id,t2.count;
>>>
>>
>> Give it up already, i was MAKING A POINT, not trying to make an
>> optimized count(*) thing :)
>> There are other examples that you cannot get around, that will be
>> evaluated more than once when a local "user variable" would make it
>> not need to.
>
> Here's an even slimmer query that makes a var:
>
> test=> select var1.* from (select 1) as var1;
> ?column?
> ----------
> 1
> (1 row)

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

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

I hope you all are kidding me in not seeing the real issue i'm trying to
show here.

Cheers
Magnus

In response to

Responses

Browse pgsql-advocacy by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-12-03 05:20:17 Re: 7.4 Wishlist
Previous Message Bruce Momjian 2002-12-03 05:02:53 Re: Segmentation fault while COPY in 7.3

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-12-03 05:20:17 Re: 7.4 Wishlist
Previous Message Egyud Csaba 2002-12-03 05:08:51 thanks for help [solved]

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-12-03 05:20:17 Re: 7.4 Wishlist
Previous Message Bruce Momjian 2002-12-03 05:02:53 Re: Segmentation fault while COPY in 7.3