From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Order of execution |
Date: | 2013-05-06 09:07:05 |
Message-ID: | km7rrp$qsh$1@gonzo.reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On 2013-05-06, JORGE MALDONADO <jorgemal1960(at)gmail(dot)com> 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
From | Date | Subject | |
---|---|---|---|
Next Message | handsfree | 2013-05-07 16:17:21 | Re: [SQL] Encrypting PGBouncer to Postgres DB connections |
Previous Message | JORGE MALDONADO | 2013-05-06 00:04:18 | Order of execution |