From: | Gregory Stark <stark(at)enterprisedb(dot)com> |
---|---|
To: | "Arjen van der Meijden" <acmmailing(at)tweakers(dot)net> |
Cc: | "Hanu Kurubar" <hanu(dot)kurubar(at)gmail(dot)com>, <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Append table |
Date: | 2007-06-02 16:36:20 |
Message-ID: | 87d50e5n5n.fsf@oxford.xeocode.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
"Arjen van der Meijden" <acmmailing(at)tweakers(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2007-06-02 19:44:33 | Re: Postgres Benchmark Results |
Previous Message | Arjen van der Meijden | 2007-06-02 16:04:19 | Re: Append table |