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 1v3XN0-000Bgt-0p for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Sep 2025 10:14:06 +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 1v3XMw-008ZxU-QL for pgsql-hackers@arkaria.postgresql.org; Tue, 30 Sep 2025 10:14:03 +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 1v3XMw-008ZxM-HB for pgsql-hackers@lists.postgresql.org; Tue, 30 Sep 2025 10:14:03 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v3XMu-000gBF-1n for pgsql-hackers@lists.postgresql.org; Tue, 30 Sep 2025 10:14:02 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3f44000626bso3513307f8f.3 for ; Tue, 30 Sep 2025 03:14:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759227240; x=1759832040; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=b4i1a/mCA1MBGd2yEEfOu6d2Rh2fg/G3ANEXH59DCHY=; b=iX8BEG+Alk3sb0uE+0lhujOU86TaeEB83VlG8ADdd9a2T177dqYmeweJUC1hcs892L sMZ+PG/JiLev7qSSUWi9/g1eT7aYLtGf5MjXsvBnDiAgr8uTWVtnV/9cXTyc6wh4bU4N OLnNxvsb03TfZbCzuCUl25VL+AQ9TnKEbGu/4+cCDyRZ+4hlsp6bPn0j6ebndqyG//uK vsq29zQu9VXz6kqlxQaLRjoR9OS/ORcgSu7/QgPNu3SOx5iNjIwP9sdLlP6d/gSfQmZh p1T1QAphfRB1bwZtdiqLFw5T639DBmt8h9nvS/KfrLXB7Bobw68fy1h9PwycsIFuczXT fR2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759227240; x=1759832040; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=b4i1a/mCA1MBGd2yEEfOu6d2Rh2fg/G3ANEXH59DCHY=; b=TVozukoVAJnBeyLdfogOcAFPKRqYrlwDdtRUVjMiSxVcqzqFAYbVF2XmElQNiKvdyE zF3kz6GKu2VHmcLGCtPsr3E/ssupSJd2xR/gE9wBxOk0brq8YKjusllQdHTPc4Fa1y83 wqVrvweqB6JFs6kATFXcomFba2TGLHWm3c0z72wALr+dWSBCQE1cy+QuEQkdpLaAskbM 4iCA7PJ1ySBekAzZhAjEXpNkMyYirxzOSmVDw9c8xbI5IoBCSyf3NlorWWGijmIH5BXQ dShHmj82bxmV07Tkv2UKx32jdqtQ09+vJa/0jKyT5ePGtiBj7oV8+iQrBHDdTTYqZFs7 HtNA== X-Forwarded-Encrypted: i=1; AJvYcCWnUJuu6a5x8BidS/YLBdRXuYgZFxmrGxuluTafH6Zy9Ox9lz/EEVeYsA5RnmK7SpeAt92T2wef6TJcuRQ3@lists.postgresql.org X-Gm-Message-State: AOJu0YySYtbVy8olAfm9zzFbANTt5ClUSzZJ4Pf0tROCe3B8G9mjcafE Ozo8yFqet/E2eb57DSIBxbIAMhZCSNP+QL/MzQDXc0AiOnOaqt+DXpWi X-Gm-Gg: ASbGncuCqhPQJ5mOOoJLtNgDfbT8fby2z7ECpumyJ0CBZ62Q7cdwrgxyej6jjygVsUt qtSpQAgatWU/Wd6Fx1jA+TNaH4ik14QMnOXbPVQF9BXdkBRkd+ocXyVy8yi3eRd0rGAIZ02V5NP jQkkCiNqisT8/KteDr0fCutpiELsVbJFsg+BeQfWCkcmpkBcH2H5G0h8kji6S4QqTsvIzSK/JVq qklvdGLh1j2xt7mO73oCH5bWMhmFCMiKoSZtQO2DvW+gvTq5wXkRsGCvoxrfFPKPuDiHEQHvhzw x7DxKfwcoKUxUXRNxm3Yk/aY1q2GjyqzOOC3p+CWgEBfT7zJnCsMYEOM24q9AaDIXdZs/kohOF4 EfyNZClZixcSKczkX6wmNhZgyuNaFKuUZZOJOV1N2e6uGFZ+1LKc4LfImVdvXlqCkSX/1TgQros P9xMDhlt7GqmuPWi8fiaW0u379ycuv8J4QxmUHPoQhfPIrwNxloIkOKCArubpoNPLI31KUXTOvm f8yrQ== X-Google-Smtp-Source: AGHT+IEpuxaST8Y7KwaaWhH06sGRd0aQmR8IPIRFXyeS41ZKguCJGVHMCa7rJ468akrtTze3GeJxOQ== X-Received: by 2002:a05:6000:26ce:b0:3e7:471c:1de3 with SMTP id ffacd0b85a97d-40e436422e6mr19325820f8f.14.1759227239598; Tue, 30 Sep 2025 03:13:59 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-181-182.eu-west-3.compute.amazonaws.com. [15.237.181.182]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-40fb89065b5sm21980756f8f.17.2025.09.30.03.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Sep 2025 03:13:58 -0700 (PDT) Date: Tue, 30 Sep 2025 10:13:57 +0000 From: Bertrand Drouvot To: Michael Paquier Cc: Kirill Reshke , Robert Haas , pgsql-hackers@lists.postgresql.org Subject: Re: relfilenode statistics Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Sep 16, 2025 at 03:44:25PM +0900, Michael Paquier wrote: > On Thu, Mar 13, 2025 at 02:00:52PM +0500, Kirill Reshke wrote: > > Hmm. While it is true that catalog lookups cannot be performed during > > crash recovery, is it really necessary to save and retrieve statistics > > after a crash? > > Yes, losing stats on crash is a *very* annoying thing. Having no > stats for a relation means that autovacuum gives up entirely on > relations it has no stats of, skipping it entirely until they have > rebuilt and bloat would accumulate. Being able to recover these stats > from crash recovery is a cheap design, that would improve reliability > by a large degree. +1. > The startup process is not connected to a database and has no access > to pg_class: the only thing we can know about are the on-disk files, > not their in-catalog OIDs. FWIW, I think that this patch would be a > huge step forward a more reliable stats system. > > True that the patch needs a rebase. Bertrand has also mentioned that > some points needed more work. Right. I'll come back with a rebase, and a POC proposal on some stats so that we could agree on the design. Also, it looks like that we have a consensus on "sometimes I don't know the relation OID so I want to use the relfilenumber instead, without changing the user experience" (see [1)). As far Michael's concern about adding a new field in the hash key, as 8 bytes is allocated for the object ID, then we can go with: dboid (linked to RelFileLocator's dbOid) objoid (linked to RelFileLocator's spcOid and to the RelFileLocator's relNumber) and avoid adding a new field in the key. [1]: https://www.postgresql.org/message-id/CA%2BTgmoZ0u6ek_xxYJaGVBk0uEvH5txoYsCwbvxKWe-2xn_G_qg%40mail.gmail.com Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com