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 1sPizH-005zln-Pr for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2024 13:28:31 +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 1sPizE-009tW5-2b for pgsql-general@arkaria.postgresql.org; Fri, 05 Jul 2024 13:28:28 +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 1sPizD-009tVx-LY for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2024 13:28:28 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sPizB-000XOf-Sl for pgsql-general@lists.postgresql.org; Fri, 05 Jul 2024 13:28:27 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-75a6c290528so960055a12.1 for ; Fri, 05 Jul 2024 06:28:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720186105; x=1720790905; darn=lists.postgresql.org; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=oyD9hQgz6KCwpuhN8sGcjP1lpmiBgwY3PX+7fbAwI+Y=; b=STxJIt4B6Ugm/EszdS4cErxuLiY9TPB65mbJ0n6QxrIV6aF6dSd3zlx4Nd8lUZliQh ++8BlW31YclougRLL+a3WoedVVgUkv9x5myb6EuH+04z011DpgIhLKjKx5FvLjv4CaoW 6uUU+IUB633sTpIL4/hwVB1VdkSFaR7L7DKo6p7EadT2Rky6HNAPiwxeO7b2dMk/wa3E flyAgwjnA1j7OL5AiYaa9UhQN3iNyIagRbmZtjGDMq0oF8ilzBIUtgzxCNwu67T5cFlk UG7OckhwtjblNgVdi1m/RUl3AIloz9vgaoWrXksnU1xw1AxX32CNrV00DdArf5MpLtRU WPRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720186105; x=1720790905; h=content-transfer-encoding:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=oyD9hQgz6KCwpuhN8sGcjP1lpmiBgwY3PX+7fbAwI+Y=; b=r3AixHjmuuBJRvmuxiQndk1X2UnmTiu62gRxAAWNFQkfGgQK25K7+6zEkJUTVp8Qsd h/uAAxPnSaAGC/bXezHCVAVZSjnSLRqgqHqMmSpuPqFh9U16Lmgg4tVasF/3IXx+CAZE SzfuDR0uiQ8RGDqOtAFgJ3U8+XMkTh9N2e07DG+JXJERoOxXrH+FsDxI2j7F6q00iI2s dczW53RFFIFeVyMyxm9TQBmilbaUslDck4M3/uhn8PV9PhNm8di6p7YOwoLN/VIbeQNS aezJvQF6RygzZo+Yv6NCG73n0CE90iHPRFB9NrhRBtYYqDirjSaEkemJE8JMha4NuVxo 4Pow== X-Gm-Message-State: AOJu0Ywv+eJWs+PV5Ic04eonOmwrf28QRikGYIOWnF3eQYbIK7NNIB8T Jlj8roLoqjQWfKKsotvXmudbodh53oL22dvjiYXuueiLWWl+yOIKCPft8Q== X-Google-Smtp-Source: AGHT+IHNIlJlzqz/QYV151HuSDQ2j06e+I7+1KBcvm6dFYYuSeclvF+AmsHULju+ldSFqXaTsTHZNw== X-Received: by 2002:a05:6a20:da8f:b0:1be:cd00:8242 with SMTP id adf61e73a8af0-1c0cc8de353mr5131742637.52.1720186104604; Fri, 05 Jul 2024 06:28:24 -0700 (PDT) Received: from ?IPV6:2402:e280:3e2e:391:fc47:3021:8361:1f06? ([2402:e280:3e2e:391:fc47:3021:8361:1f06]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c99a9cd3e7sm3347604a91.39.2024.07.05.06.28.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 05 Jul 2024 06:28:24 -0700 (PDT) Message-ID: <3eed1916-a166-42b7-862e-692887336652@gmail.com> Date: Fri, 5 Jul 2024 18:58:21 +0530 MIME-Version: 1.0 User-Agent: Betterbird (Linux) Content-Language: en-US To: pgsql-general@lists.postgresql.org From: Krishnakant Mane Subject: confused about material view locks please explain Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello all. I am an old timer postgresql user for last 17 years. I have used it for my open source as well as enterprise cloud services. IN my current fintech solution, I need to do some performance optimisations. I have decided to use materialised views (more precisely IVM ). So on my postgresql version 16, I have installed pg_ivm extention. I have one fundamental question before going ahead with it's actual use in production. So, I have a voucher master and voucher details table. This system pertains to double entry book keeping (debit and credit types ). master contains id as serial primary key, date, voucher type and narration along with invoice number. details table contains the id as foreign key, account code, again foreign key from the accounts table, drcrtype being integer (3 for credit and 4 for debit ). So a view joining vouchermaster, voucherdetails and accounts is created. Every time an invoice is generated, both the master and detail table will get updated. the voucher view is used for generating reports such as balance sheet, profit loss and cash flow. 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 possible, I would like to avoid a lock on the view or at least allow selects on the view while it is being incrementally updated. Is this possible? Regards.