Re: Is replacing transactions with CTE a good idea?

From: Brian Dunavant <dunavant(at)gmail(dot)com>
To: Glen Huang <heyhgl(at)gmail(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Is replacing transactions with CTE a good idea?
Date: 2021-04-01 14:58:25
Message-ID: CAJ2+uGUYptunbADng2ywqq_pKuKSFS8aTpoLiLJz-9-qhWqcSw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 1, 2021 at 10:49 AM Glen Huang <heyhgl(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dave Cramer 2021-04-01 15:04:04 Re: Is replacing transactions with CTE a good idea?
Previous Message Glen Huang 2021-04-01 14:49:38 Is replacing transactions with CTE a good idea?