Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oslJP-0007YF-Gn for pgsql-general@arkaria.postgresql.org; Wed, 09 Nov 2022 13:40:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oslJN-0003Ol-Sz for pgsql-general@arkaria.postgresql.org; Wed, 09 Nov 2022 13:40:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oslJN-0003Oc-DU for pgsql-general@lists.postgresql.org; Wed, 09 Nov 2022 13:40:13 +0000 Received: from smtp55.i.mail.ru ([217.69.128.35]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oslJG-0005Od-7C for pgsql-general@lists.postgresql.org; Wed, 09 Nov 2022 13:40:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=aeronavigator.ru; s=mailru; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:In-Reply-To:References:To:From:From:Subject:Content-Type:Content-Transfer-Encoding:To:Cc; bh=+ubagXRHELmUA62qJxFUgIKVJQjDoXQgcYWw07KAlP4=; t=1668001206;x=1668091206; b=RM+G/coJXoCazyMHVn8PC6zWg5Uf6fsbaWhLTIdzVSK5TFFnBFQ95ozZtNwMmO0Curf23LL9YRCdIRZKF1JNCTL6fhu8yqAKPNlJumKmck+jXicUsHIJ403bAZ4AOhSAHJ04xIygMFp8O9w90mIRkG0NcXYzGriz4MnE0FEB7mU=; Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1oslJE-0000Sk-PC; Wed, 09 Nov 2022 16:40:05 +0300 From: To: "'Laurenz Albe'" , References: <012801d8f42c$06ea5af0$14bf10d0$@aeronavigator.ru> In-Reply-To: Subject: RE: Unnecessary locks for partitioned tables Date: Wed, 9 Nov 2022 16:40:01 +0300 Message-ID: <01a401d8f440$c48bf320$4da3d960$@aeronavigator.ru> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 16.0 Thread-Index: AQIhkX7s0zf1CV96ReVGH4N9IwvxigH2hb26rZWlH3A= Content-Language: ru Authentication-Results: smtp55.i.mail.ru; auth=pass smtp.auth=n.kobzarev@aeronavigator.ru smtp.mailfrom=n.kobzarev@aeronavigator.ru X-Mailru-Src: smtp X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD967121363E257EE6DA4EF366E81877C7C8F138EE5791C383500894C459B0CD1B9672B288B1A9E4C882ACED978327432B50EDB217CDAF1A5AA6941F327F1033F36 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7ACA11F7F2395C8CCEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F91103FA893F53AB8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D844B95D5552A2BB3EE55BD917A51C8789117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC47272755C61AA17BA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520C24E1E72F37C03A028451B159A507268D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE652FD71AFB96DC7D8FBB52F5C7ECD1BBD8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE386D40F53BA1922956136E347CC761E07C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F790063772BA5C7373F6D986EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3463DBE2ADA183F62FC2674E88FA9F6BB7EEBB72A9B1F3E6EA76CAB240F20CE0DDEFD156B33640234E1D7E09C32AA3244C4E4081FB00770AB8BFDBEC4192B3DFC995A9E0DC41E9A4CF729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojDvKINbZCEhI2h7B8+GgJoA== X-Mailru-Sender: 657AADBC28A10CF51E40C46096C03D8FF191F2FE6E25018C3E024F0D844CDA68E6EFB8CE349225569215EFA742CC5EB292D99EB8CC7091A74C2ED15A5AB7F0073B9C7E7614533D2A011BE29E39D2FEA10D4ABDE8C577C2ED X-Mras: Ok List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > > On Wed, 2022-11-09 at 14:11 +0300, n.kobzarev@aeronavigator.ru = wrote: > > Recently I`ve been pushing into life a new project and immediately=20 > > experienced an Out of shared memory error while querying partitioned = tables. > > =20 > > ERROR: out of shared memory > > Hint: You might need to increase max_locks_per_transaction. > > =20 > > Ok, let`s increase max_locks_per_transaction, but why this type of = query produces so much locks? > > Looks like DB issues locks for all the partitioned objects involved = in=20 > > query and ONLY AFTER THAT it does partition pruning. > Yes, of course. It needs an ACCESS SHARE lock when it looks at = metadata like the partition constraint, and locks > are held until the = end of the transaction. > Yours, > Laurenz Albe > -- > Cybertec | https://www.cybertec-postgresql.com Thank you for reply! But why it is not necessary in case of custom plan?=20 Oh, I did not explicitly write that, in case of custom plan (first = attempts or with force_custom_plan) database holds only a couple of = locks! Why in this case it is sufficient to lock only one partition and = parent table ?