Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lT2YQ-0000ts-FU for pgsql-general@arkaria.postgresql.org; Sun, 04 Apr 2021 13:12:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lT2YP-00041g-D6 for pgsql-general@arkaria.postgresql.org; Sun, 04 Apr 2021 13:12:37 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lT2YP-00041Y-68 for pgsql-general@lists.postgresql.org; Sun, 04 Apr 2021 13:12:37 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lT2YM-000244-5D for pgsql-general@lists.postgresql.org; Sun, 04 Apr 2021 13:12:36 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1lT2YJ-0005qp-OR; Sun, 04 Apr 2021 09:12:31 -0400 Date: Sun, 4 Apr 2021 09:12:31 -0400 From: Bruce Momjian To: Dave Cramer Cc: Glen Huang , "pgsql-generallists.postgresql.org" Subject: Re: Is replacing transactions with CTE a good idea? Message-ID: <20210404131231.GA1730@momjian.us> References: <7CFF1F8C-E83D-4A68-AD89-6DD3FE2E2493@gmail.com> <20210401193929.GA18029@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, Apr 4, 2021 at 08:35:41AM -0400, Dave Cramer wrote: > > > On Thu, 1 Apr 2021 at 15:39, Bruce Momjian wrote: > > On Thu, Apr  1, 2021 at 11:24:48AM -0400, Dave Cramer wrote: > > CTE's don't change the isolation level. I'm not sure what you are getting > at > > here ? > > I think what he/she means here is that all queries in a CTE use a single > snapshot, meaning you don't see changes by commits that happen between > queries that are part of the same CTE.  If you were running the queries > separately in read committed mode, you would see those changes, but you > would not see them in repeatable read or serializable transaction mode. > > OK, that makes sense, but I think it is wrong minded to think that this > absolves one of taking isolation into account. > > When you make the first read you will still have to deal with all of the > isolation issues  I have no idea what you are saying above. Why is a SELECT-only CTE not the same as a repeatable-read SELECT-only multi-statement transaction? Are you saying that a SELECT in a CTE doesn't do SELECT FOR UPDATE? -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.