Re: confused about material view locks please explain - Mailing list pgsql-general

From Peter J. Holzer
Subject Re: confused about material view locks please explain
Date
Msg-id 20240705154035.qjoey3eaqaqitthn@hjp.at
Whole thread Raw
In response to confused about material view locks please explain  (Krishnakant Mane <kkproghub@gmail.com>)
Responses Re: confused about material view locks please explain
List pgsql-general
On 2024-07-05 18:58:21 +0530, Krishnakant Mane wrote:
> I have decided to use materialised views (more precisely IVM ).
[...]
> Given this setup I have a very specific questionh.
>
> if client 1 has asked for his balance sheet and the view is being queried,
> then what will happen if client 2 happens to create an invoice concurrently?
>
> Will the invoice creation (and subsequent voucher table and view update )
> wait for client 1 to complete the select query, or will the select query
> halt till the update happen?

If I understand https://github.com/sraoss/pg_ivm correctly, the
materialized view will be updated within the same transaction. So it's
just the same as any other change in the database:

Neither client will wait for the other. The first client will see either
the old or the new state depending on whether the second client manages
to commit soon enough.

        hp

--
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | hjp@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment

pgsql-general by date:

Previous
From: Matt Hughes
Date:
Subject: Planning of sub partitions
Next
From: Matt Hughes
Date:
Subject: Re: Planning of sub partitions