Re: big distinct clause vs. group by
От | Robert Haas |
---|---|
Тема | Re: big distinct clause vs. group by |
Дата | |
Msg-id | 4B594466-0554-4AF8-A8BC-8FDA9C393DF9@gmail.com обсуждение исходный текст |
Ответ на | Re: big distinct clause vs. group by (Uwe Bartels <uwe.bartels@gmail.com>) |
Ответы |
Re: big distinct clause vs. group by
Re: big distinct clause vs. group by |
Список | pgsql-performance |
On Apr 18, 2011, at 1:13 PM, Uwe Bartels <uwe.bartels@gmail.com> wrote: > Hi Robert, > > thanks for your answer. > the aggregate function I was talking about is the function I need to use for the non-group by columns like min() in myexample. > There are of course several function to choose from, and I wanted to know which causes as less as possible resources. Oh, I see. min() is probably as good as anything. You could also create a custom aggregate that just always returns its firstinput. I've occasionally wished we had such a thing as a built-in. Another option is to try to rewrite the query with a subselect so that you do the aggregation first and then add the extracolumns by joining against the output of the aggregate. If this can be done without joining the same table twice, it'soften much faster, but it isn't always possible. :-( ...Robert
В списке pgsql-performance по дате отправления: