which Update quicker

From: Emi Lu <emilu(at)encs(dot)concordia(dot)ca>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: which Update quicker
Date: 2014-09-23 19:35:09
Message-ID: 5421CB6D.70401@encs.concordia.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello list,

For a big table with more than 1,000,000 records, may I know which
update is quicker please?

(1) update t1
set c1 = a.c1
from a
where pk and
t1.c1 <> a.c1;
......
update t1
set c_N = a.c_N
from a
where pk and
t1.c_N <> a.c_N;

(2) update t1
set c1 = a.c1 ,
c2 = a.c2,
...
c_N = a.c_N
from a
where pk AND
( t1.c1 <> a.c1 OR t1.c2 <> a.c2..... t1.c_N <> a.c_N)

Or other quicker way for update action?

Thank you
Emi

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Daniele Varrazzo 2014-09-23 20:39:13 Re: which Update quicker
Previous Message Daniel Lenski 2014-09-23 18:54:09 Re: Where art thou, plpython2.dll? (EDB installer)