Re: Question about locking

From: Frank Millman <frank(at)chagford(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Question about locking
Date: 2022-08-07 06:22:22
Message-ID: 080a1a96-a4df-fb73-cae9-44c58258b927@chagford.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 2022-08-07 7:54 AM, Ron wrote:
> On 8/7/22 00:30, Frank Millman wrote:
>> Hi all
>>
>> Apologies if this is an FAQ, but I could not find the answer I was
>> looking for.
>>
>> I want to run two SELECTs, one immediately after the other.
>>
>> I want to ensure that no other process updates the database in
>> between the two.
>>
>> What is the best way to achieve this?
>
> You probably want to put the queries in a Repeatable Read transaction,
> or even a READ ONLY serialized transaction.
> https://www.postgresql.org/docs/12/transaction-iso.html#XACT-REPEATABLE-READ
>
> https://www.postgresql.org/docs/12/transaction-iso.html#XACT-SERIALIZABLE
> https://www.postgresql.org/docs/12/sql-set-transaction.html
>
Thanks, Ron. That is exactly what I am looking for.

Frank

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tomas Vondra 2022-08-07 17:23:52 Re: Expr. extended stats are skipped with equality operator
Previous Message Ron 2022-08-07 05:54:28 Re: Question about locking