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 1nYsQw-0002z9-T5 for pgsql-general@arkaria.postgresql.org; Mon, 28 Mar 2022 16:41:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nYsQv-00089y-Kh for pgsql-general@arkaria.postgresql.org; Mon, 28 Mar 2022 16:41:33 +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 1nYsQu-00089p-I6 for pgsql-general@lists.postgresql.org; Mon, 28 Mar 2022 16:41:33 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nYsQr-0003Wt-Fc for pgsql-general@postgresql.org; Mon, 28 Mar 2022 16:41:31 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id C82DB3200EC0; Mon, 28 Mar 2022 12:41:27 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 28 Mar 2022 12:41:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; bh=8Q/5+e5YnUlr+E 9IWO1A8UzPLBw/4o49cgN0JoyrWOU=; b=eXkj+TXljPVky6IqmS1rJD6RiNhjhl /BEf0JZN9I+7q7JSbezTVI6HBFIiPcwqDXBFhydVHplUW57AurZwNAjwAcvF0FxT LAvzk6OvBfrDlFHJu2iwRH5RbxfMXVPZLhPDjxa35YCb0r0ilphzxPLs8j2wVdIC ficI/ppK6HKnmXTRuphSjPt+/MUYtpWGC0BOT0Lv7ZosDXNy+9oAiGLE60+vxMIP ohgNIu2+Ejm+iNsY5ZU0iWSorOzIRkc1NMj79ofU4WsIVtfDDMeH7oiFYroG2c5d dlYnOPHLIa6li0hLDqaqC39k3s9gGHO6Fo8Ca7rlSEXSBOVsO6X0dmZA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=8Q/5+e5YnUlr+E9IWO1A8UzPLBw/4o49cgN0JoyrWOU=; b=ePQQLor9 Wa7vkxmNgFmLg9a/SQuaTnVLVfDnsKtp7RWahTIKlqpAgkCbmHH4w4kTmucu15qu pbDafN+UK0tyDrSjsCrLh0ZGXsHEUjIn3+15J5JpZtl5h0ltr+9dJSPqyqE/cM6W rXZWBTYBcEIiZorW1J6vS2FL1QVfzJ7ICniwjAwMfP89GqS+aaXWhTpmf8ERAsQ7 8zrcqFl1aPNG/UFL0U1OmJ4XL1iAVflpenban0ekp/ZGeRQYk8GV2C1GpNzSzqnz v5eZZCvxXiUpc180HpCAsPuzuKKq30KyqoUmBH7qaz9L/18zvn1DXiKU7j+ZwH7n HYYQU/x2IiNAAg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrudehjedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepvedvkeeihfduhffhtdekleegffduiefgteejgeff gffhteefleeludfgleelgeevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 28 Mar 2022 12:41:26 -0400 (EDT) Message-ID: Date: Mon, 28 Mar 2022 09:41:25 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: Performance issues on FK Triggers after replacing a primary column Content-Language: en-US To: Per Kaminsky , "pgsql-general@postgresql.org" , Tom Lane References: <8ed0c2ae-8a35-2628-4b41-68f9cb734297@aklaver.com> <733c2f32-e808-9024-2332-b0a972ac0bb0@aklaver.com> <524b0b1c-d351-0a9f-01e5-1f60eeda5fe8@aklaver.com> From: Adrian Klaver In-Reply-To: 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 On 3/28/22 09:39, Per Kaminsky wrote: > Do you mean a simple "ANALYZE VERBOSE A"? Or something different? > Following the thought that maybe the index got stale, i just tried to > add a "REINDEX TABLE B". This did not help as well, which might be the > case, if an index (re)build is always deferred until the end of the > transaction (which i don't know if that is the case). The ANALYZE would be more about telling the planner that the data in tables changed and what they changed to, then anything to do with the index. For this you really don't need the VERBOSE. > > ------------------------------------------------------------------------ > *From:* Adrian Klaver > *Sent:* Monday, March 28, 2022 17:59 > *To:* Per Kaminsky ; > pgsql-general@postgresql.org ; Tom Lane > > *Subject:* Re: Performance issues on FK Triggers after replacing a > primary column > On 3/28/22 08:47, Per Kaminsky wrote: >> The tables have Index to each other on each foreign key. The index >> itself was not touched though, and a remove/recreate did not help. Could >> it be possible, that when the PK and FK values are replaced the Index is >> not (immediately) updated and thus cannot be used? > > Have you tried an ANALYZE on "A" AND "B" after?: > > UPDATE "A" SET id = id_temp; > > As to the index not immediately updating, I don't know. > > >> >> The temporary table is not shown. It is created to insert the new values >> from file, then used to update the correct table with the new values, >> and then removed, it has no connection (FK or something else) to any >> other table. >> > > So that is the '// fill id_temp with new IDs' part? > > > -- > Adrian Klaver > adrian.klaver@aklaver.com -- Adrian Klaver adrian.klaver@aklaver.com