Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryz7r-001Oy3-JG for pgsql-general@arkaria.postgresql.org; Mon, 22 Apr 2024 19:14:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ryz7p-00DPkY-Ls for pgsql-general@arkaria.postgresql.org; Mon, 22 Apr 2024 19:14:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryz7n-00DPkB-LT for pgsql-general@lists.postgresql.org; Mon, 22 Apr 2024 19:14:49 +0000 Received: from fout7-smtp.messagingengine.com ([103.168.172.150]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryz7k-0048I7-0A for pgsql-general@postgresql.org; Mon, 22 Apr 2024 19:14:46 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 438B21380238; Mon, 22 Apr 2024 15:14:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 22 Apr 2024 15:14:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1713813282; x=1713899682; bh=hqbaPhOtg1hClSlOJ0apInQ+4YvDV1GmJEx6xqiQlBg=; b= JAAzTirXNzbu2yIBQ68/leW02imQjGQynDWVMJJI/00Vju9VFOoeB8npFJkNYyX8 fFVdFDnkelQtbJuDlE3zgHZySoT9k0nbbwY9U+T1Ju2sJsh41xUA3Ix78f5TAm8M wUWQKxQn9ThPi1DhRYsuRreZK8qFXI96mtDWrj5veL4JbKMW+SSoTtq+QctmYlLd M1KKbMGB5xuRR7q3cQQuzvQuznCBBBO6mNn/VSHC8nhZjb3q9Sk3SrNVLbSKF8An HLUGokrN+1bDP+KmKzBWwWfOrs1MXZ4Uw24fbJx2A28+0fEW8blSdwdEMpNHjxi9 Jlf9duuY/gS0MyLaM0w4ww== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1713813282; x= 1713899682; bh=hqbaPhOtg1hClSlOJ0apInQ+4YvDV1GmJEx6xqiQlBg=; b=B UtB4+ZS+VMkQJEITPhoL5x60qw9hnxvTPVkTwcg2LeVfbhAiKqnauGnSr5CIqxzE rnJouBzeHiKgIjQ01YMCLv1OpGvYS7TSjhrblAttspb24Oq3wKU3NfaJq0wgLqLH vH/7d5CV273Iv/kaJk7T1tcE01c1tQxUvxQotH0jyqLC7Ka5/JEiRduIy2eUeAP8 gv6CG9ZVPdCHvw76gmevToLIgyITDkQeIjDMk4fzBCXvs3PSsCPOwIXDa16fLRe2 l8m4+0crv+lU6+zDw9RFoi2ZZ4QlijbVPTN9/4djvHefDn1UYbgpkcca9FYEKe49 2ti5xN/ozUS0n8dbF9p+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudekledgudefhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesth ekredttddvjeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdr khhlrghvvghrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpeffleegie efgfevudehtdfhkeeutdffjeevgeffgeejvedthefgudeiteefheejheenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrughrihgrnhdrkhhlrg hvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 22 Apr 2024 15:14:40 -0400 (EDT) Message-ID: <632e3176-13e4-4863-b8b9-bc1aba778268@aklaver.com> Date: Mon, 22 Apr 2024 12:14:38 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: CLUSTER vs. VACUUM FULL To: Ron Johnson , pgsql-general References: <2870091.1713739514@sss.pgh.pa.us> <3043219.1713795953@sss.pgh.pa.us> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 4/22/24 11:45 AM, Ron Johnson wrote: > On Mon, Apr 22, 2024 at 12:29 PM David G. Johnston > > wrote: > > > > On Mon, Apr 22, 2024, 08:37 Ron Johnson > wrote: > > On Mon, Apr 22, 2024 at 10:25 AM Tom Lane > wrote: > > Marcos Pegoraro > writes: > > But wouldn't it be good that VACUUM FULL uses that index > defined by > > Cluster, if it exists ? > > No ... what would be the difference then? > > What the VACUUM docs "should" do, it seems, is suggest CLUSTER > on the PK, if the PK is a sequence (whether that be an actual > sequence, or a timestamp or something else that grows > monotonically). > > That's because the data is already roughly in PK order. > > > If things are bad enough to require a vacuum full that doesn't seem > like a good assumption. > > > Sure it does. > > For example, I just deleted the oldest half of the records in 30 > tables.  Tables who's CREATED_ON timestamp value strongly correlates to > the synthetic PK sequence values. > > Thus, the remaining records were still mostly in PK order.  CLUSTERs on > the PK values would have taken just about as much time as the VACUUM > FULL statements which I /did/ run. 1) If they are already in enough of a PK order that the CLUSTER time vs VACUUM FULL time would not be material as there is not much or any sorting to do then what does the CLUSTER gain you? Unless this table then became read only whatever small gain arose from the CLUSTER would fade away as UPDATEs and DELETEs where done. 2) What evidence is there that the records where still in PK order just because you deleted based on CREATED_ON? I understand the correlation between CREATED_ON and the PK just not sure why that would necessarily translate to an on disk order by PK? -- Adrian Klaver adrian.klaver@aklaver.com