Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZHmZ-0004R4-9v for pgsql-sql@arkaria.postgresql.org; Mon, 06 May 2013 09:32:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UZHmY-0004Pf-NL for pgsql-sql@arkaria.postgresql.org; Mon, 06 May 2013 09:32:30 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZHmX-0004PZ-OL for pgsql-sql@postgresql.org; Mon, 06 May 2013 09:32:29 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UZHmT-0002jJ-8N for pgsql-sql@postgresql.org; Mon, 06 May 2013 09:32:28 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1UZHmR-0004q3-Nd for pgsql-sql@postgresql.org; Mon, 06 May 2013 11:32:23 +0200 Received: from ip-118-90-66-240.xdsl.xnet.co.nz ([118.90.66.240]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 May 2013 11:32:23 +0200 Received: from jasen by ip-118-90-66-240.xdsl.xnet.co.nz with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 06 May 2013 11:32:23 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: Jasen Betts Subject: Re: Order of execution Date: 6 May 2013 09:07:05 GMT Organization: JJ's own news server Lines: 31 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: ip-118-90-66-240.xdsl.xnet.co.nz X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-18 (Linux) X-Pg-Spam-Score: -3.1 (---) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 2013-05-06, JORGE MALDONADO wrote: > --089e013d1eb83325e504dc01710d > Content-Type: text/plain; charset=ISO-8859-1 > > I have an UPDATE query which performs several opertions in one table. > > UPDATE table01 SET > field1 = (query1 may contain any field), > field2 = (query1 may contain any field), > field3 = (query1 may contain any field) > WHERE (condition) > > query1, query2 and query3 perform a logic to determine which records will > be updated. Does field1 updates first, then field2 and, lastly, field3? Updates are one row at a time in an unpredictble order. this will be wrapped in a transaction so either all will updated or none. testing suggests that in simple cases the expressions are evaluated in the order the columns appear in the table definition, but I wouldn't rely on that. > or What is the order in which updates are executed? If I need fields to be > updated in a certain order, should I use 3 UPDATE commands instead? yeah, if "simultaneously" isn't acceptable you'll need to do separate updates. -- ⚂⚃ 100% natural -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql