From: Gregory Stark <stark@enterprisedb.com>
To: Arjen van der Meijden <acmmailing@tweakers.net>
Cc: Hanu Kurubar <hanu.kurubar@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Append table
Date: Sat, 02 Jun 2007 17:36:20 +0100
Message-ID: <87d50e5n5n.fsf@oxford.xeocode.com> (raw)
In-Reply-To: <46619503.2050509@tweakers.net>
References: <912b58490705302036n3c528b6fq4bfaa693a9e58dd7@mail.gmail.com>
<912b58490706020852r61d308b3m595bf410d89a113@mail.gmail.com>
<46619503.2050509@tweakers.net>
"Arjen van der Meijden" <acmmailing@tweakers.net> writes:
> There are two solutions:
...
> Or you can visually combine them without actually putting the records in a
> single table. That can be with a normal select-union statement or with a view,
> something like this:
> SELECT EmpId, EmpName FROM tabelA UNION EmpID, EmpName FROM tabelB;
If you're sure the two sets are distinct or you want to get any duplicates and
not eliminate them then if you went with this option you would want to use
"UNION ALL" not just a plain union.
In SQL UNION has to remove duplicates which often involves gathering all the
records and performing a big sort and lots of extra work. UNION ALL is much
faster and can start returning records right away.
--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: stark@enterprisedb.com, acmmailing@tweakers.net, hanu.kurubar@gmail.com
Subject: Re: Append table
In-Reply-To: <87d50e5n5n.fsf@oxford.xeocode.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox