From: Emi Lu <emilu@encs.concordia.ca>
To: pgsql-performance@postgresql.org
Subject: update - which way quicker?
Date: Thu, 28 Aug 2008 15:31:04 -0400
Message-ID: <48B6FCF8.3090807@encs.concordia.ca> (raw)
Good morning,
Tried to compare Table1 based on Table2
. update table1.col = false
if table1.pk_cols not in table2.pk_cols
For the following two ways, (2) always performs better than (1) right,
and I need your inputs.
========================================================================
(1) update table1
set col = false
where table1.pk_co1 || table1.pk_col2.... || table1.pk_colN
NOT IN
(select pk_co1 || pk_col2.... || pk_colN
from table2
)
(2) ResultSet(rs) =
select pk_col1||pk_col2... || pk_colN
from table1
left join table2 using (pk_col1..., pk_colN)
where table2.pk_col1 is null
Then for each rs record, do:
update table1
set col = false
where col1||... colN in rs.value
Thanks a lot!
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: emilu@encs.concordia.ca
Subject: Re: update - which way quicker?
In-Reply-To: <48B6FCF8.3090807@encs.concordia.ca>
* 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