pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Is replacing transactions with CTE a good idea?
Date: Sat, 3 Apr 2021 21:06:31 -0500
Message-ID: <b6567fde-6617-2144-177e-857ce980dc4a@gmail.com> (raw)
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>

On 4/1/21 10:04 AM, Rob Sargent wrote:
> 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"?

That's the only way to explain an otherwise very puzzling question. OP must 
not do lots of DML in each transaction.

-- 
Angular momentum makes the world go 'round.

view thread (22+ messages)  latest in thread

Message-ID: <b6567fde-6617-2144-177e-857ce980dc4a@gmail.com>
Permalink:  ../b6567fde-6617-2144-177e-857ce980dc4a@gmail.com/
Also on:    postgresql.org/message-id/b6567fde-6617-2144-177e-857ce980dc4a@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: ronljohnsonjr@gmail.com
  Subject: Re: Is replacing transactions with CTE a good idea?
  In-Reply-To: <b6567fde-6617-2144-177e-857ce980dc4a@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> <b6567fde-6617-2144-177e-857ce980dc4a@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