2010/12/12 pasman pasmaÅski <pasman.p@xxxxxxxxx>: >> 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 -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance