Re: update with from

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: update with from
Date: 2012-01-23 15:50:59
Message-ID: 29808.1327333859@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sim Zacks <sim(at)compulab(dot)co(dot)il> writes:
> I want to update a table with a from that has mutliple rows joining to
> it. According to the docs, this is not advisable because:
> "If it does, then only one of the join rows will be used to update the
> target row, but which one will be used is not readily predictable."

That means exactly what it says.

> In my tests, if the joined rows are sorted it always updates with the
> first row. Does anyone have any other experiences, or should I be
> concerned that at some point it will behave differently?

If you rely on this, your code *will* break some day. Probably at
3AM while you're on vacation. All it takes is a plan change.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roger Leigh 2012-01-23 16:16:22 Re: Schema version control
Previous Message Sim Zacks 2012-01-23 15:32:35 Re: update with from