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.96) (envelope-from ) id 1vfai6-0039k2-2o for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 09:29:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vfai4-003mSC-24 for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jan 2026 09:29:08 +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.96) (envelope-from ) id 1vfai4-003mS4-0S for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 09:29:08 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vfai1-000AnE-2U for pgsql-hackers@lists.postgresql.org; Tue, 13 Jan 2026 09:29:07 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-47ed9b04365so2817675e9.0 for ; Tue, 13 Jan 2026 01:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768296545; x=1768901345; 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=kgT2gbJ9cg9p7HQJ2yP61atwYvUzATyN6UXvOnhx2Vo=; b=OWpu2TTTkodhVRCC0KOOpgFyMxUnjTfJweJcxa8DH7FPRR+/aMEUSaEdn/l1qTN/9h /+0YPEWrPe+Dt80dfd7yWqOVf9/5IBB5a2o2gSpA787yWsvYc160Tb2/eVeE4HZD4ZDf M0x1tZIOpnUrRTVQW6jCAE5gU+SLXw6/fCACoKLtZKQ17NSN3t7pLVDbPxxzH3ObBPPK 4CIJx2Ku87HWaB9yQK663WplHvS0JqPJtDNh3HL9/JLK/yWwiN008d9rt+r553H7jvra ANAGc4/13pU2bhxp73E6rbfovDYEFdsXpUHwPZ9g5HmWbiMZMdR6v/qNOj9z2tYoSAjD Ho5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768296545; x=1768901345; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kgT2gbJ9cg9p7HQJ2yP61atwYvUzATyN6UXvOnhx2Vo=; b=bVX2YR7H6QFQNpzx6JuWwFYwTZT395vAxOzErjKQBxazdiP5z3By59EKuOvku1Wd5s 5m9xTLJlwtjWThs1s9sXdP4Koyuf6bD0HPm4Oyc6MNZSa3mOxxFapn4V+3CbCtkK8MGw ym1IuDXWvxN1GMEUf7s/iuz+VdI+2TAyDp4IJJzmvKr8QWqUQjI5smbP4b4H6//V8BRf 7Qo+Q+mx9gc6sghQ0tZ6SnVR+6TPMwGLinM0ZX6RvVTAmhJmxiayCP2iHkMbtMlDP3jN bGzHZx09g00JBz0VPpz8FS7jgZl3prJASLu7fNdjZd+MQRylizTmIBZWC+r0yZInERv/ cV+A== X-Forwarded-Encrypted: i=1; AJvYcCW3KmoDUwmurMDaTQaIZtn7KZPm/a4/X5GgYFTbFycvDXHsu2KCkaTstg1SQoiB6EjslvlSO2sXeVGmncDn@lists.postgresql.org X-Gm-Message-State: AOJu0Yx9iyM22YmLMAcUUSTTvdv98k4iDbXNOAP+qyNWkezgjDv1SdYk ijUGSW7SPvkdOgIB96r6DCNm9huVfBMuzmTycA2YZbdPazmPXxq1BmvT X-Gm-Gg: AY/fxX4/5pMl3G4SY8LfnGmVH2rNF/yeM4JcNaj9qJLCCetkYgMGn238ogw1ecnyA9W s0xTA7Wq9QOAgVVJk8yGkri47pyUxwmGEWYZb/RcaijQCisa545QvYuNh67KCX7Zk4uBPchaRZq J9D/auE1NFs1qThWOSk0/qOaga11Y5qlPVPtLTkjSgH0Px8u3YB5L50pvjgJ4z1CkYVSZ/hURvr 7zwlzRs9PZRaKO8F5Qge6IndD1HfzV3MAz0IrVaXm7vwve6sBKzz+hiJlx4XQu7hEdSUJOgU7ve 5AvuTq6R+1U9hHLRil5Gfe9LY2FzS2FAGrBcVIArf25/9fIqrTZCXncb3W8biYQh2/xWNgyCeEo iAKuQimS9casZtNQV3jlTk6pP3UzpQygGHoRmndjuQzrHkAi0sH9+Y3j3c1Y4i2hjZsr7OV8rmT 0PIXdAITC5++RIUTb7eX8PNbOnRwZg5j9xj4w6UYKCGVEGzOGONNTiEXpn3vmJO2TbznBkf8exI amQx3F97kPMP0t2iZKmMUCkjiqfaadC3FKqFm4VACkWdQ== X-Google-Smtp-Source: AGHT+IFeddZi9OayU7OUtgxBB1UtSDUQTEjebKlZqZa9nTS+poT8rZHQwbsEHJWOrdUxMCr4XeW/7Q== X-Received: by 2002:a05:600c:8b57:b0:47d:586e:2fea with SMTP id 5b1f17b1804b1-47d84b182a7mr239137195e9.15.1768296544436; Tue, 13 Jan 2026 01:29:04 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47eda0ee80bsm11640165e9.4.2026.01.13.01.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 01:29:03 -0800 (PST) Date: Tue, 13 Jan 2026 09:29:02 +0000 From: Bertrand Drouvot To: Andres Freund , 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, Dec 16, 2025 at 10:39:15AM -0500, Andres Freund wrote: > On 2025-12-16 16:33:17 +0900, Michael Paquier wrote: > > > > FWIW, I am also still troubled by the part of the proposed patch set > > where we are trying to hide the idea of a partitioned table has a > > relfilenode set by using its relid instead in the key for the data. > > This leads to a huge amount of complexity in the patch, mainly to > > store data for autovacuum that we do not need at the end: > > - autovacuum discards partitioned tables in do_autovacuum(), so the > > stats related to partitioned tables that we need to select the > > relations does not matter. > > I feel like that's an implementation wart that we ought to fix. It's not > infrequently a problem that we don't automatically analyze partitioned > tables. Weren't there even a couple threads on that on the list in the last > weeks? > > > > - manual vacuums may include partitioned tables to extract its > > partitions, vacuum_rel() at the end discarding them. Well, stats > > don't matter anyway. > > > > We only need to attach three fields to let autovacuum know if a > > relation needs to run or not: dead_tuples, ins_since_vacuum, > > mod_since_analyze. > > That may be true for autovacuum today, but I don't see any reason for > live_tuples, tuples_inserted etc to be inaccurate after a failover. > > > Most the fields of PgStat_StatTabEntry make sense > > only for tables, few are required by indexes for pg_stat_all_indexes. > > Some fields actually make sense because they refer to on-disk files, > > mostly for pg_statio_all_tables (blocks_fetched, blocks_hit). > > > > Hence, why don't we split PgStat_StatTabEntry into three things from > > the start, even if it means to duplicate some of them? Say: > > - Table fields: includes [auto]vacuum/analyze data, block fields, > > fields of pg_stat_all_tables. > > What do you mean with "block fields"? pg_statio_all_tables? If so, what's the > point of including them here, rather than in the relfilenode fields? > > > > - Index fields: no need for the [auto]vacuum/analyze time and counts, > > block fields, pg_stat_all_indexes fields. > > I think we actually should populate the [auto]vac fields for indexes, right > now it's impossible to figure out from stats whether indexes are frequently > scanned as part of vacuum or not. > > > > - Relfilenode fields: dead_tuples, ins_since_vacuum and > > mod_since_analyze. Does not apply to partitioned tables and indexes, > > only applies to tables. Provides a clean split, embrace the fact that > > these are the only three fields we need to worry about during > > recovery. > > I think we really ought to populate not just these during recovery, but also > at least n_tup_ins, n_tup_upd, n_tup_del, n_tup_hot_upd, n_live_tup. > > I don't understand why we would want to only populate these three fields? > > > I'm not against splitting the index fields off, but it seems pretty orthogonal > to what we're discussing here. If we were to split of index stats into a > separate stat, why wouldn't we keep the statio fields in the relfilenode > stats, since they're obviously intimately tied to that? Andres, Michael, let me try to sum up my understanding of the current state and see how we could now move forward. First of all, I understand that you both think that the patch outcome will be useful to have. The current debate is about the design, the current status is: - Andres raised specific technical/implementation concerns and I've proposed solutions in [1]. It also looks like Andres supports the overall design approach. - Michael is not really ok with the current design approach. That means, that with the current design in place, Michael would probably not commit it (even after review(s)). Given that I'm also in favor of the current proposed design, this raises the questions: - Andres, would you commit such a patch (after review iteration(s) of course)? - Michael, if Andres is ok with the above, would you still offer your help for the review part (even if the design is not what you "prefer"/"like")? [1]: https://postgr.es/m/aUEyzoOJtrCLAEeT%40ip-10-97-1-34.eu-west-3.compute.internal Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com