Re: confused about material view locks please explain

From: "Peter J(dot) Holzer" <hjp-pgsql(at)hjp(dot)at>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: confused about material view locks please explain
Date: 2024-07-05 15:40:35
Message-ID: 20240705154035.qjoey3eaqaqitthn@hjp.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)hjp(dot)at | -- Charles Stross, "Creative writing
__/ | http://www.hjp.at/ | challenge!"

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matt Hughes 2024-07-05 16:06:13 Re: Planning of sub partitions
Previous Message Matt Hughes 2024-07-05 15:24:23 Planning of sub partitions