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 1mMtxI-0005sg-D6 for pgsql-general@arkaria.postgresql.org; Sun, 05 Sep 2021 15:21:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mMtxH-0006cN-1D for pgsql-general@arkaria.postgresql.org; Sun, 05 Sep 2021 15:21:11 +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 1mMtxG-0006cF-OX for pgsql-general@lists.postgresql.org; Sun, 05 Sep 2021 15:21:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mMtxE-00008x-0G for pgsql-general@lists.postgresql.org; Sun, 05 Sep 2021 15:21:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 185FL62V2875219; Sun, 5 Sep 2021 11:21:06 -0400 From: Tom Lane To: "David G. Johnston" cc: Philippe Doussot , "pgsql-general@lists.postgresql.org" Subject: Re: update non-indexed value is slow if some non-related index/fk are enabled In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Sun, 05 Sep 2021 08:08:23 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2875217.1630855266.1@sss.pgh.pa.us> Date: Sun, 05 Sep 2021 11:21:06 -0400 Message-ID: <2875218.1630855266@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Friday, September 3, 2021, Philippe Doussot > wrote: >> I don't understand why disabling all index from the table speed up the >> update because the boolean column is not indexed > Index entries point to physical records. You just deleted one physical > record and added another. The indexes need to be updated with that > information. Yeah. The OP's mental model is apparently update-in-place, but that's not how Postgres does things. The index-update overhead is avoided if the update is "HOT", which requires that (a) no indexed column changes and (b) there is room on the same page for the new copy of the row. Ensuring (b) requires running with a fairly low fill-factor, which bloats your table and thereby creates its own costs. Still, that might be worth doing depending on your particular circumstances. regards, tom lane