pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Question about locking
3+ messages / 2 participants
[nested] [flat]

* Question about locking
@ 2022-08-07 05:30 Frank Millman <frank@chagford.com>
  2022-08-07 05:54 ` Re: Question about locking Ron <ronljohnsonjr@gmail.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Frank Millman @ 2022-08-07 05:30 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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?

Thanks

Frank Millman







^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Question about locking
  2022-08-07 05:30 Question about locking Frank Millman <frank@chagford.com>
@ 2022-08-07 05:54 ` Ron <ronljohnsonjr@gmail.com>
  2022-08-07 06:22   ` Re: Question about locking Frank Millman <frank@chagford.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Ron @ 2022-08-07 05:54 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

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

-- 
Angular momentum makes the world go 'round.





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Question about locking
  2022-08-07 05:30 Question about locking Frank Millman <frank@chagford.com>
  2022-08-07 05:54 ` Re: Question about locking Ron <ronljohnsonjr@gmail.com>
@ 2022-08-07 06:22   ` Frank Millman <frank@chagford.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Frank Millman @ 2022-08-07 06:22 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org


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







^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-08-07 06:22 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-08-07 05:30 Question about locking Frank Millman <frank@chagford.com>
2022-08-07 05:54 ` Ron <ronljohnsonjr@gmail.com>
2022-08-07 06:22   ` Frank Millman <frank@chagford.com>

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