Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPl3H-006Czt-O9 for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2024 15:40:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sPl3E-00BADj-Mc for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2024 15:40:45 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPl3E-00BAD2-A6 for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2024 15:40:45 +0000 Received: from mail.hjp.at ([212.17.106.138] helo=rorschach.hjp.at) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sPl38-000YPF-J4 for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2024 15:40:43 +0000 Received: by rorschach.hjp.at (Postfix, from userid 1000) id 395F718D72; Fri, 5 Jul 2024 17:40:35 +0200 (CEST) Date: Fri, 5 Jul 2024 17:40:35 +0200 From: "Peter J. Holzer" To: pgsql-general@lists.postgresql.org Subject: Re: confused about material view locks please explain Message-ID: <20240705154035.qjoey3eaqaqitthn@hjp.at> Mail-Followup-To: pgsql-general@lists.postgresql.org References: <3eed1916-a166-42b7-862e-692887336652@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="sbkbznt52x4owvfi" Content-Disposition: inline In-Reply-To: <3eed1916-a166-42b7-862e-692887336652@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --sbkbznt52x4owvfi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. >=20 > 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 concurrent= ly? >=20 > 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 --=20 _ | Peter J. Holzer | Story must make more sense than reality. |_|_) | | | | | hjp@hjp.at | -- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" --sbkbznt52x4owvfi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEETtJbRjyPwVTYGJ5k8g5IURL+KF0FAmaIE+oACgkQ8g5IURL+ KF0v9Q//SW04mPG7bGjlKSJaBJFADT/lr3VD9G/yPKMBm0wO1HvR7SEt29wQ9gV5 SGGtaQrSw/V+pDxA6xHGEtOxa3pB6/TLQxrrB3p8cgiqm4Ej/Oe5rVGiTiJhgVsK 1mXvaLnq8OgrSdnEMEnips/ETCGDQzDqNPWvFiVCVq8WwYP1hx4jpTkoXbkS7Ds1 hOZrejQUfEVjOmm5SBXz+ELMAJBC7vdI9dwjYKcYNPmn2mev3AImsmHzJSQzjjkt F/YGqBdJ2ouOpxKGxusqS9s7y5RSKzcLBWK7JCyAFDDdPABJIHUk0vgvKth4KJaJ 2nr3L/8KmjcOAEJ17wajari9cCAFTHwejhZB1KDdlW8gB6ozO+h1SDNK3+2SxzTU PnUqm+ks0BBM/TL/7AMeQhvUWu2atWPY0KNOsbElohcWkmte3viPCe1UXBj4L82F k+hQe+7wJ/VItgk8Sy/Rs1FlNhe5jSFpj7yY62lmMk2/V2pOV5E4GW3X6pyY9IkT 4ODKzun1t3oUccx8/gM4Gfyd01J0Kf3l/QxHbDJqPOzpmcqZu+bnAabrTiIeiWen 0gGNPiCF87Fcnh1YlHLbkwk9QfQcmellhOme0OEc3MgpSR8dtQ+YXgouklK3bf9s IDqc9AxNma3qyx9te01AmBs/B3T/nCMA63IIQ42jkO3I+NKMqXA= =bMWD -----END PGP SIGNATURE----- --sbkbznt52x4owvfi--