Re: Is replacing transactions with CTE a good idea?

From: Glen Huang <heyhgl(at)gmail(dot)com>
To: Dave Cramer <davecramer(at)postgres(dot)rocks>
Cc: "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Is replacing transactions with CTE a good idea?
Date: 2021-04-01 15:29:57
Message-ID: 640147B9-3A7C-4281-87C4-C94C2A907D60@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I had the impression that since they are chained together, somehow they run “tighter” 😂.

Thanks for pointing out that mistake.

> On Apr 1, 2021, at 11:25 PM, Dave Cramer <davecramer(at)postgres(dot)rocks> wrote:
>
> 
> CTE's don't change the isolation level. I'm not sure what you are getting at here ?
>
> Dave Cramer
> www.postgres.rocks
>
>
>> On Thu, 1 Apr 2021 at 11:20, Glen Huang <heyhgl(at)gmail(dot)com> wrote:
>> Sorry, my mistake. I misunderstood serializable. Are queries in a CTE equivalent to those in a repeatable read transaction?
>>
>>>> On Apr 1, 2021, at 11:10 PM, Dave Cramer <davecramer(at)postgres(dot)rocks> wrote:
>>>>
>>> 
>>>
>>>
>>>> On Thu, 1 Apr 2021 at 11:09, Glen Huang <heyhgl(at)gmail(dot)com> wrote:
>>>> No, but are they equivalent to serializable transactions?
>>>
>>> No, they are not.
>>>
>>>
>>>
>>> Dave Cramer
>>> www.postgres.rocks
>>>>
>>>>>> On Apr 1, 2021, at 11:04 PM, Dave Cramer <davecramer(at)postgres(dot)rocks> wrote:
>>>>>>
>>>>> 
>>>>>
>>>>>
>>>>>
>>>>>> On Thu, 1 Apr 2021 at 10:50, Glen Huang <heyhgl(at)gmail(dot)com> wrote:
>>>>>> Hi all,
>>>>>>
>>>>>> From application’s standpoint, it seems using CTE saves a lot work. You no longer need to parse values out only to pass them back in, and only one round-trip to the db server.
>>>>>>
>>>>>> If I’m not wrong, CTE is equivalent to serializable transactions? So I guess the downsize is that quarries can’t be run in parallel?
>>>>>
>>>>> I do not think a CTE changes the isolation level.
>>>>>>
>>>>>> If I decide to replace all my transaction code with CTE, will I shoot myself in the foot down the road?
>>>>>
>>>>>
>>>>> Dave Cramer
>>>>> www.postgres.rocks

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marc Millas 2021-04-01 15:32:30 storage in mem
Previous Message Glen Huang 2021-04-01 15:26:47 Re: Is replacing transactions with CTE a good idea?