Re: Group By and wildcards...

From: "Sim Zacks" <sim(at)nospam(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Group By and wildcards...
Date: 2005-02-20 06:27:42
Message-ID: cv9ao9$2ege$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Even if the function did a select from d, it could still have plenty of
duplicates. To remove that possibility you would have to use the distinct
clause which is also generally less efficient then a group by.

"Bruno Wolff III" <bruno(at)wolff(dot)to> wrote in message
news:20050219192033(dot)GA24244(at)wolff(dot)to(dot)(dot)(dot)
> On Sat, Feb 19, 2005 at 14:02:34 -0500,
> Oisin Glynn <me(at)oisinglynn(dot)com> wrote:
> >
> > But the where clause defines the result of the aggregate function (in
this
> > case the SUM)?
>
> Not really.
>
> > Is the only reason for needing the GROUP BY CLAUSE is because the
aggregate
> > function demands it?
>
> Note that there is also a join to a table d. So that values in d are
> being summed up based on some connection from d to the other 3 tables.
>
> > If so could something like the following work where we pass the where
clause
> > conditions into the function and it performs the aggregate function and
> > returns.. I am guessing this would be extremely inefficient?
> >
> > select A.*,B.*,C.*,my_cheating_sum(a.id,b.id,c.id) from a,b,c,
> > where some conditions;
>
> If that function did a select from d, you could make this work, but it
> would likely be much slower than doing it in one SQL statement.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Sim Zacks 2005-02-20 06:30:47 Re: Newbie: PG8 and text file parsing
Previous Message Tom Lane 2005-02-20 05:32:31 Re: PGSQL 8.0.1 Win 2K Installation Problem