Re: Speed difference between select ... union select ... and select from partitioned_table

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: Speed difference between select ... union select ... and select from partitioned_table
Дата
Msg-id 1193432821.7624.83.camel@dogma.ljc.laika.com
обсуждение исходный текст
Ответ на Speed difference between select ... union select ... and select from partitioned_table  (Pablo Alcaraz <pabloa@laotraesquina.com.ar>)
Ответы Re: Speed difference between select ... union select ... and select from partitioned_table
Список pgsql-performance
On Fri, 2007-10-26 at 16:37 -0400, Pablo Alcaraz wrote:
> Hi List!
>
> I executed 2 equivalents queries. The first one uses a union structure.
> The second uses a partitioned table. The tables are the same with 30
> millions of rows each one and the returned rows are the same.
>
> But the union query perform faster than the partitioned query.
>

I think you mean to use UNION ALL here. UNION forces a DISTINCT, which
results in a sort operation. What surprises me is that the UNION is
actually faster than the partitioning using inheritance.

I suspect it has something to do with the GROUP BYs, but we won't know
until you post EXPLAIN ANALYZE results.

    Regards,
    Jeff Davis


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

Предыдущее
От: Pablo Alcaraz
Дата:
Сообщение: Speed difference between select ... union select ... and select from partitioned_table
Следующее
От: Gregory Stark
Дата:
Сообщение: Re: Suggestions on an update query