pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Is replacing transactions with CTE a good idea?
Date: Thu, 1 Apr 2021 09:04:29 -0600
Message-ID: <02654280-7b22-1231-8de7-c74a1a62e426@gmail.com> (raw)
In-Reply-To: <CAJ2+uGUYptunbADng2ywqq_pKuKSFS8aTpoLiLJz-9-qhWqcSw@mail.gmail.com>
References: <DED55D28-088A-432E-B961-15567A5BD1CC@gmail.com>
	<CAJ2+uGUYptunbADng2ywqq_pKuKSFS8aTpoLiLJz-9-qhWqcSw@mail.gmail.com>

On 4/1/21 8:58 AM, Brian Dunavant wrote:
> On Thu, Apr 1, 2021 at 10:49 AM Glen Huang <heyhgl@gmail.com 
> <mailto:heyhgl@gmail.com>> wrote:
>
>     If I decide to replace all my transaction code with CTE, will I
>     shoot myself in the foot down the road?
>
>
> I do this all the time and makes code way cleaner.   It's very 
> straightforward with inserts queries.  When you deal with 
> updates/deletes, things can be trickier.  I usually leave these in a 
> transaction if there is any concern.
>
> They can also be hard for future programmers that may not understand 
> SQL.  Make sure you comment your queries for maintainability long term.
>
> I have yet to regret replacing a transaction with a CTE over the past 
> decade.  YMMV
This must assume auto-commit mode where every single statement is 
"committed"?

view thread (22+ messages)  latest in thread

Message-ID: <02654280-7b22-1231-8de7-c74a1a62e426@gmail.com>
Permalink:  ../02654280-7b22-1231-8de7-c74a1a62e426@gmail.com/
Also on:    postgresql.org/message-id/02654280-7b22-1231-8de7-c74a1a62e426@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: robjsargent@gmail.com
  Subject: Re: Is replacing transactions with CTE a good idea?
  In-Reply-To: <02654280-7b22-1231-8de7-c74a1a62e426@gmail.com>
  References: <DED55D28-088A-432E-B961-15567A5BD1CC@gmail.com> <CAJ2+uGUYptunbADng2ywqq_pKuKSFS8aTpoLiLJz-9-qhWqcSw@mail.gmail.com> <02654280-7b22-1231-8de7-c74a1a62e426@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox