From: | Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com> |
---|---|
To: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: With Update From ... vs. Update ... From (With) |
Date: | 2015-04-14 02:38:41 |
Message-ID: | 552C7DB1.2030206@BlueTreble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 4/13/15 8:12 PM, David G. Johnston wrote:
> Hello!
>
> Is there any non-functional difference between these two forms of Update?
>
> WITH name AS ( SELECT )
> UPDATE tbl SET ...
> FROM name
> WHERE tbl.id <http://tbl.id> = name.id <http://name.id>
>
> and
>
> UPDATE tbl SET ...
> FROM ( WITH qry AS ( SELECT ) SELECT * FROM qry ) AS name
> WHERE tbl.id <http://tbl.id> = name.id <http://name.id>
>
> They both better give the same results but does the backend treat them
> differently?
>
> Does the answer to my question depend on the version of PostgreSQL?
Well, they're both ugly... but see what EXPLAIN or EXPLAIN VERBOSE shows.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-04-14 03:13:39 | Re: bigserial continuity safety |
Previous Message | Jim Nasby | 2015-04-14 02:37:37 | Re: Help with slow table update |