Re: Why query takes soo much time

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Why query takes soo much time
Дата
Msg-id 15163.1305555359@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Why query takes soo much time  (Denis de Bernardy <ddebernardy@yahoo.com>)
Список pgsql-performance
Denis de Bernardy <ddebernardy@yahoo.com> writes:
> An alternative plan could have been to hash join the tables together,
> to sort the result set, and to apply the limit/offset on the resulting
> set.

Indeed.  I rather wonder why the planner didn't do that to start with.
This plan looks to me like it might be suffering from insufficient
work_mem to allow use of a hash join.  Or possibly the OP changed some
of the cost_xxx or enable_xxx settings in a misguided attempt to force
it to use indexes instead.  As a rule of thumb, whole-table joins
probably ought not be using nestloop plans, and that frequently means
that indexes are worthless for them.

But in any case, as Craig noted, the real elephant in the room is the
huge OFFSET value.  It seems likely that this query is not standing
alone but is meant as one of a series that's supposed to provide
paginated output, and if so the total cost of the series is just going
to be impossible no matter what.  The OP needs to think about using a
cursor or some such to avoid repeating most of the work each time.

            regards, tom lane

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

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: KVP table vs. hstore - hstore performance (Was: Postgres NoSQL emulation)
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [PERFORMANCE] expanding to SAN: which portion best to move