Re: Any advice tuning this query ?

Поиск
Список
Период
Сортировка
От Andreas Karlsson
Тема Re: Any advice tuning this query ?
Дата
Msg-id d9eb436f-7d9b-60f6-7f08-3c63579f9781@proxel.se
обсуждение исходный текст
Ответ на Any advice tuning this query ?  (Henrik Ekenberg <henrik@ekenberg.pw>)
Список pgsql-performance
I have a couple of suggestions which should lead to some minor
improvements, but in general I am surprised by the huge size of the
result set. Is your goal really to get a 43 million row result? When a
query returns that many rows usually all possible query plans are more
or less bad.

1) You can remove "3" from the group by clause to avoid having to sort
that data when we already sort by d.date.

2) If (books, date) is the primary key of dates_per_books we can also
safely remove "4" from the group by clause further reducing the length
of the keys that we need to sort.

3) For a minor speed up change "coalesce(sum(case when i.invno is not
null then 1 else 0 end),0)" to "count(i.invno)".

Andreas


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

Предыдущее
От: "ldh@laurent-hasson.com"
Дата:
Сообщение: Re: Inlining of functions (doing LIKE on an array)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Inlining of functions (doing LIKE on an array)