Re: queries with lots of UNIONed relations

От: Tom Lane
Тема: Re: queries with lots of UNIONed relations
Дата: ,
Msg-id: 18301.1294959904@sss.pgh.pa.us
(см: обсуждение, исходный текст)
Ответ на: Re: queries with lots of UNIONed relations  (Robert Haas)
Ответы: Re: queries with lots of UNIONed relations  (Jon Nelson)
Список: pgsql-performance

Скрыть дерево обсуждения

queries with lots of UNIONed relations  (Jon Nelson, )
 Re: queries with lots of UNIONed relations  (Tom Lane, )
  Re: queries with lots of UNIONed relations  (Jon Nelson, )
   Re: queries with lots of UNIONed relations  (Tom Lane, )
    Re: queries with lots of UNIONed relations  (Jon Nelson, )
     Re: queries with lots of UNIONed relations  (Robert Haas, )
      Re: queries with lots of UNIONed relations  (Tom Lane, )
       Re: queries with lots of UNIONed relations  (Robert Haas, )
        Re: queries with lots of UNIONed relations  (Robert Haas, )
         Re: queries with lots of UNIONed relations  (Andy Colson, )
          Re: queries with lots of UNIONed relations  (Robert Haas, )
           Re: queries with lots of UNIONed relations  (Andy Colson, )
           Re: queries with lots of UNIONed relations  (Jon Nelson, )
         Re: queries with lots of UNIONed relations  (Tom Lane, )
        Re: queries with lots of UNIONed relations  (Tom Lane, )
         Re: queries with lots of UNIONed relations  (Jon Nelson, )
          Re: queries with lots of UNIONed relations  (Tom Lane, )
           Re: queries with lots of UNIONed relations  (Jon Nelson, )
            Re: queries with lots of UNIONed relations  (Jon Nelson, )
        Re: queries with lots of UNIONed relations  (Mladen Gogala, )
       Re: queries with lots of UNIONed relations  (Vitalii Tymchyshyn, )

Robert Haas <> writes:
> On Thu, Jan 13, 2011 at 5:26 PM, Tom Lane <> wrote:
>> I don't believe there is any case where hashing each individual relation
>> is a win compared to hashing them all together. �If the optimizer were
>> smart enough to be considering the situation as a whole, it would always
>> do the latter.

> You might be right, but I'm not sure.  Suppose that there are 100
> inheritance children, and each has 10,000 distinct values, but none of
> them are common between the tables.  In that situation, de-duplicating
> each individual table requires a hash table that can hold 10,000
> entries.  But deduplicating everything at once requires a hash table
> that can hold 1,000,000 entries.

> Or am I all wet?

If you have enough memory to de-dup them individually, you surely have
enough to de-dup all at once.  It is not possible for a single hashtable
to have worse memory consumption than N hashtables followed by a union
hashtable, and in fact if there are no common values then the latter eats
twice as much space because every value appears twice in two different
hashtables.

            regards, tom lane


В списке pgsql-performance по дате сообщения:

От: Mladen Gogala
Дата:
Сообщение: Re: queries with lots of UNIONed relations
От: Craig Ringer
Дата:
Сообщение: Re: The good, old times