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 1qH0IC-0006WI-OE for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Jul 2023 11:03:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qH0IB-0001VE-Lh for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Jul 2023 11:03:27 +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 1qH0IB-0001V5-Cb for pgsql-hackers@lists.postgresql.org; Wed, 05 Jul 2023 11:03:27 +0000 Received: from mail-wr1-f42.google.com ([209.85.221.42]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qH0I8-0029lZ-Sq for pgsql-hackers@lists.postgresql.org; Wed, 05 Jul 2023 11:03:26 +0000 Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-31297125334so515681f8f.0 for ; Wed, 05 Jul 2023 04:03:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688555002; x=1691147002; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=E6rkZ+E89A6u08NdCex0Js3a/NnX1imbPQvV+pVXg1A=; b=c6steYm7glQ1qFcjN6D7eP3aAo4AwaVXvlzrKL+zjMxHOh5qWquPFNh6oqZajvOeSn Myl9GLGQ9Y/7TOPVskMCbC2n2TelPM0TQLB1WdVpgVQB65awD5kRJ1HuPu4iRb2kvkAm etF11wxkeaYnZpON7OFSFgYVlLTkkdUO8nr+lYeT8xXEaQs77A/MLnUyW6c1ZDXm0X2b VPKoSVykU50wFYjBYjnhWI7eNkIR5O7vnzKcMAZ7+EIOXZkuq5T6O9oYxrJNIDAAOzmK whkNoHd/ta2K+4n5LMRHFaC+As1BKX6YLXCS6qwDsMpJxjRmAqpT+OkXeSHpHYiBOtoO jNYA== X-Gm-Message-State: ABy/qLYq39WMrf7iJ0wXAfHkM5nz3nNqtG+PS8Phqs/Ulxu8QwqLB9KT 5Rxqv+YiYyilk2Vt+OyQkJmavO5i0k/zYiOvrFg= X-Google-Smtp-Source: APBJJlHpx/l5VOXV0z/pnFvAhu6Eghdr26PfS7aPWB5mcWQFriQq2Q8r2LJTllaLMji/jRVFfUKnEo5oSbOqAyVAnY8= X-Received: by 2002:a5d:420d:0:b0:314:3f1:cebf with SMTP id n13-20020a5d420d000000b0031403f1cebfmr2029231wrq.28.1688555001871; Wed, 05 Jul 2023 04:03:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Thom Brown Date: Wed, 5 Jul 2023 12:02:55 +0100 Message-ID: Subject: Re: Disabling Heap-Only Tuples To: Matthias van de Meent Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 5 Jul 2023 at 11:57, Matthias van de Meent wrote: > > On Wed, 5 Jul 2023 at 12:45, Thom Brown wrote: > > Heap-Only Tuple (HOT) updates are a significant performance > > enhancement, as they prevent unnecessary page writes. However, HOT > > comes with a caveat: it means that if we have lots of available space > > earlier on in the relation, it can only be used for new tuples or in > > cases where there's insufficient space on a page for an UPDATE to use > > HOT. > > > > This mechanism limits our options for condensing tables, forcing us to > > resort to methods like running VACUUM FULL/CLUSTER or using external > > tools like pg_repack. These either require exclusive locks (which will > > be a deal-breaker on large tables on a production system), or there's > > risks involved. Of course we can always flood pages with new versions > > of a row until it's forced onto an early page, but that shouldn't be > > necessary. > > > > Considering these trade-offs, I'd like to propose an option to allow > > superusers to disable HOT on tables. The intent is to trade some > > performance benefits for the ability to reduce the size of a table > > without the typical locking associated with it. > > Interesting use case, but I think that disabling HOT would be missing > the forest for the trees. I think that a feature that disables > block-local updates for pages > some offset would be a better solution > to your issue: Normal updates also prefer the new tuple to be stored > in the same pages as the old tuple if at all possible, so disabling > HOT wouldn't solve the issue of tuples residing in the tail of your > table - at least not while there is still empty space in those pages. Hmm... I see your point. It's when an UPDATE isn't going to land on the same page that it relocates to the earlier available page. So I guess I'm after whatever mechanism would allow that to happen reliably and predictably. So $subject should really be "Allow forcing UPDATEs off the same page". Thom