Re: slow sort

Поиск
Список
Период
Сортировка
От Maximilian Tyrtania
Тема Re: slow sort
Дата
Msg-id 6E353E0A-1DA2-452A-BD91-DF6BE916F05D@contactking.de
обсуждение исходный текст
Ответ на Re: slow sort  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-performance
Am 11.09.2013 um 17:31 schrieb Andrew Dunstan <andrew@dunslane.net>:

> I recently had to diagnose and remedy a case such as this.
>
> The short answer is to rewrite your query so you don't have to group by so many things. Collect your aggregates in a
commontable expression query (or possibly more than one, depends what you need) using the minimum non-aggregated
columnsto enable you to get correct results and then later decorate that with all the extra things you need such as
constantcolumns and columns that are irrelevant to the aggregation. 
>
> This gets hard when queries are very complex, and harder still when the query is written by a query generator. But a
goodgenerator should not just say "grouo by everything that's not aggregated" and think it's doing a good job. In your
caseit should be relatively straightforward. 
>
> cheers
>
> andrew

Ah, yes, only now do I see that the query screams for a CTE. Thanks for the eye opener.

Maximilian Tyrtania
http://www.contactking.de

В списке pgsql-performance по дате отправления:

Предыдущее
От: Roberto Grandi
Дата:
Сообщение: Re: COPY TO and VACUUM
Следующее
От: Souquieres Adam
Дата:
Сообщение: Memory-olic query and Materialize