Re: hash join vs nested loop join

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: hash join vs nested loop join
Дата
Msg-id 20121212234732.80090@gmx.com
обсуждение исходный текст
Ответ на hash join vs nested loop join  (Huan Ruan <leohuanruan@gmail.com>)
Ответы Re: hash join vs nested loop join  (Huan Ruan <huan.ruan.it@gmail.com>)
Список pgsql-performance
Huan Ruan wrote:

> is a lot slower than a nested loop join.

Giving actual numbers is more useful than terms like "a lot". Even
better is to provide the output of EXPLAIN ANALYZZE rather than
just EXPLAIN. This shows estimates against actual numbers, and give
timings. For more suggestions see this page:

http://wiki.postgresql.org/wiki/SlowQueryQuestions

> I don't understand why the optimiser chooses the hash join in
> favor of the nested loop. What can I do to get the optimiser to
> make a better decision (nested loop in this case)? I have run
> analyze on both tables.

> Config changes are
>
>  - shared_buffers = 6GB
>  - effective_cache_size = 18GB
>  - work_mem = 10MB
>  - maintenance_work_mem = 3GB

As already suggested, there was a change made in 9.2 which may have
over-penalized nested loops using index scans. This may be fixed in
the next minor release.

Also, as already suggested, you may want to reduce random_page
cost, to bring it in line with the actual cost relative to
seq_page_cost based on your cache hit ratio.

Additionally, I just routinely set cpu_tuple_cost higher than the
default of 0.01. I find that 0.03 to 0.05 better models the actual
relative cost of processing a tuple.

-Kevin


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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Do I have a hardware or a software problem?
Следующее
От: Amitabh Kant
Дата:
Сообщение: Limit & offset effect on query plans