Re: UNION and bad performance - Mailing list pgsql-performance

From Robert Haas
Subject Re: UNION and bad performance
Date
Msg-id AANLkTinC0ZcS1N54T-jmpj3VPWVnW15apmWVCKucgnD0@mail.gmail.com
Whole thread Raw
In response to Re: UNION and bad performance  (pasman pasmański <pasman.p@gmail.com>)
Responses Re: UNION and bad performance  (pinker <pinker@onet.eu>)
List pgsql-performance
2010/12/12 pasman pasmański <pasman.p@gmail.com>:
>> UNION will remove all duplicates, so that the result additionally requires to
>> be sorted.
>
>>Right, to avoid the SORT and UNIQUE - operation you can use UNION ALL
>
>
> by the way maybe apply hashing to calculate UNION be better ?

The planner already considers such plans.

rhaas=# explain select a from generate_series(1,100) a union select a
from generate_series(1,100) a;
                                      QUERY PLAN
--------------------------------------------------------------------------------------
 HashAggregate  (cost=45.00..65.00 rows=2000 width=4)
   ->  Append  (cost=0.00..40.00 rows=2000 width=4)
         ->  Function Scan on generate_series a  (cost=0.00..10.00
rows=1000 width=4)
         ->  Function Scan on generate_series a  (cost=0.00..10.00
rows=1000 width=4)
(4 rows)

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

pgsql-performance by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: postgres performance tunning
Next
From: tuanhoanganh
Date:
Subject: Re: PostgreSQL 9.0 x64 bit pgbench TPC very low question?