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 1kjt98-0002qk-Pb for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Dec 2020 00:03:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kjt96-00014c-V0 for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Dec 2020 00:03:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjt96-00014V-55 for pgsql-hackers@lists.postgresql.org; Tue, 01 Dec 2020 00:03:52 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kjt93-0008Fg-Qa for pgsql-hackers@lists.postgresql.org; Tue, 01 Dec 2020 00:03:51 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 906B05C0100; Mon, 30 Nov 2020 19:03:48 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 30 Nov 2020 19:03:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=woEAsnEmwigOaefr4 G0cXKnghj3p8/pfGFSMv3EQEaA=; b=rpaq0E4lg4X3D84Bbq+7yIB7vsg3dlUP/ CmQOGDjJzJPKqYn0WRagaUjt0FYxQz8Fkg6bY6aLwboSJIlkxpP98y/bSESk/kU5 r2mOm0eGtAJtRdudXAguVx0hk5/Iqg0mSE3N9tZO9PFJawSG9WC909471S0jtryx JBmyHyTEa//SE11d7Z4RmproOrTrWFDbWiXvaldnGkZP4xiTXL6zGQHz+ZFUbc1s EClEgu8NQ6n8Z/sABskUOA8nnj0zzf/SmQOygI63KeYInjpkBUiRVgq8QPNXTipL etWoW5f6LktEKQuMdi1bmJ1jwTDzZAcJx24faSTL14E4Ln/Xl9mWA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedrudeiuddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkgggtuggjfgesthdtre dttdervdenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvefgleevgeeuje eghfegteeghfegheeifeehheelteetieduieeihffggfehffetnecukfhppeduledtrdel hedrudekrdejleenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfh hrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: from perhan.alvh.no-ip.org (unknown [190.95.18.79]) by mail.messagingengine.com (Postfix) with ESMTPA id B5CB2328005E; Mon, 30 Nov 2020 19:03:47 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 646712A14FE; Mon, 30 Nov 2020 21:03:45 -0300 (-03) Date: Mon, 30 Nov 2020 21:03:45 -0300 From: Alvaro Herrera To: Kyotaro Horiguchi Cc: keisuke.kuroda.3862@gmail.com, tatsuro.yamada.tf@nttcom.co.jp, pgsql-hackers@lists.postgresql.org, amitlangote09@gmail.com, tatsuhito.kasahara.rd@hco.ntt.co.jp Subject: Re: Huge memory consumption on partitioned table with FKs Message-ID: <20201201000345.GA15098@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126.121818.26523414172308697.horikyota.ntt@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-Nov-26, Kyotaro Horiguchi wrote: > This shares RI_ConstraintInfo cache by constraints that shares the > same parent constraints. But you forgot that the cache contains some > members that can differ among partitions. > > Consider the case of attaching a partition that have experienced a > column deletion. I think this can be solved easily in the patch, by having ri_BuildQueryKey() compare the parent's fk_attnums to the parent; if they are equal then use the parent's constaint_id, otherwise use the child constraint. That way, the cache entry is reused in the common case where they are identical. I would embed all this knowledge in ri_BuildQueryKey though, without adding the new function ri_GetParentConstOid. I don't think that function meaningful abstraction value, and instead it would make what I suggest more difficult.