Re: How to change order sort of table in HashJoin

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to change order sort of table in HashJoin
Дата
Msg-id 21633.1479572313@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How to change order sort of table in HashJoin  (Man Trieu <man.trieu@gmail.com>)
Ответы Re: How to change order sort of table in HashJoin
Список pgsql-hackers
Man Trieu <man.trieu@gmail.com> writes:
> As in the example below, i think the plan which hash table is created on
> testtbl2 (the fewer tuples) should be choosen.

The planner usually prefers to hash on the table that has a flatter
MCV histogram, since a hash table with many key collisions will be
inefficient.  You might find it illuminating to read the comments around
estimate_hash_bucketsize().

In general, given a hashtable that fits in memory and light bucket
loading, a hash join is more or less O(M) + O(N); it doesn't matter
so much whether the larger table is on the inside.  It does matter if
the table gets big enough to force batching of the join, but that's
not happening in your example (at least not the first one; it's unclear
to me why it did happen in the second one).  The key thing that will
drive the choice, then, is avoiding a skewed bucket distribution that
causes lots of comparisons for common values.

            regards, tom lane


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

Предыдущее
От: "Karl O. Pinc"
Дата:
Сообщение: Re: Patch to implement pg_current_logfile() function
Следующее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: Mail thread references in commits