From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruno Wolff III <bruno@wolff.to>
Cc: pgsql-sql@postgresql.org
Subject: Re: Using union to avoid creating temp table
Date: Mon, 01 Jul 2002 13:17:30 -0400
Message-ID: <15083.1025543850@sss.pgh.pa.us> (raw)
In-Reply-To: <20020701163140.GA22475@wolff.to>
References: <20020701163140.GA22475@wolff.to>
Bruno Wolff III <bruno@wolff.to> writes:
> What I ended up doing is building the input values into sepearte
> select statements unioned together. So if the input values were
> 'abc', 'def' and 'ghi', I would end up doing a select like:
> select add.id from (select 'abc' union select 'def' union select 'ghi') add (id)where not exists (select from role where add.id = role.id)
Might be worth writing "union all" not "union". This suppresses union's
check for duplicated rows, which you presumably don't need.
regards, tom lane
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, bruno@wolff.to
Subject: Re: Using union to avoid creating temp table
In-Reply-To: <15083.1025543850@sss.pgh.pa.us>
* 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