From: | Uwe Bartels <uwe(dot)bartels(at)gmail(dot)com> |
---|---|
To: | Robert Klemme <shortcutter(at)googlemail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: big distinct clause vs. group by |
Date: | 2011-04-19 08:47:16 |
Message-ID: | BANLkTi=KcJh3FFgzTtM=3onJFZaY+=xNLw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
Hi Robert,
Oh, I do care about these columns.
But by using an group by on the key columns, I cannot select the columns as
they are. Otherwise you get an error message.
So I have to use an aggregate functionlike min().
Best...
Uwe
On 19 April 2011 10:24, Robert Klemme <shortcutter(at)googlemail(dot)com> wrote:
> On Mon, Apr 18, 2011 at 7:13 PM, Uwe Bartels <uwe(dot)bartels(at)gmail(dot)com>
> wrote:
> > the aggregate function I was talking about is the function I need to use
> for
> > the non-group by columns like min() in my example.
> > There are of course several function to choose from, and I wanted to know
> > which causes as less as possible resources.
>
> If you do not care about the output of the non key columns, why do you
> include them in the query at all? That would certainly be the
> cheapest option.
>
> If you need _any_ column value you can use a constant.
>
> rklemme=> select * from t1;
> k | v
> ---+---
> 0 | 0
> 0 | 1
> 1 | 2
> 1 | 3
> 2 | 4
> 2 | 5
> 3 | 6
> 3 | 7
> 4 | 8
> 4 | 9
> (10 rows)
>
> rklemme=> select k, 99 as v from t1 group by k order by k;
> k | v
> ---+----
> 0 | 99
> 1 | 99
> 2 | 99
> 3 | 99
> 4 | 99
> (5 rows)
>
> rklemme=>
>
> Greetings from Paderborn
>
> robert
>
> --
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
>
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Klemme | 2011-04-19 08:57:49 | Re: How to configure a read-only database server? |
Previous Message | Robert Klemme | 2011-04-19 08:24:18 | Re: big distinct clause vs. group by |