Re: queries with lots of UNIONed relations

From: Vitalii Tymchyshyn <tivv00(at)gmail(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: queries with lots of UNIONed relations
Date: 2011-01-14 11:39:04
Message-ID: 4D3035D8.8030800@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

14.01.11 00:26, Tom Lane написав(ла):
> Robert Haas<robertmhaas(at)gmail(dot)com> writes:
>> On Thu, Jan 13, 2011 at 3:12 PM, Jon Nelson<jnelson+pgsql(at)jamponi(dot)net> wrote:
>>> I still think that having UNION do de-duplication of each contributory
>>> relation is a beneficial thing to consider -- especially if postgresql
>>> thinks the uniqueness is not very high.
>> This might be worth a TODO.
> 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.
>
>
How about cases when individual relations are already sorted? This will
mean that they can be deduplicated fast and in streaming manner. Even
partial sort order may help because you will need to deduplicate only
groups with equal sorted fields, and this will take much less memory and
be much more streaming. And if all individual deduplications are
streaming and are sorted in one way - you can simply do a merge on top.

Best regards, Vitalii Tymchyshyn.

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mike Broers 2011-01-14 16:36:43 Re: plan question - query with order by and limit not choosing index depends on size of limit, table
Previous Message Craig Ringer 2011-01-14 06:02:28 Re: The good, old times