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 1w2DT9-0005rz-2n for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 19:19:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w2DT7-00CF6U-2X for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Mar 2026 19:19:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w2DT7-00CF6J-1W for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2026 19:19:14 +0000 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w2DT5-00000000Tbg-39Hv for pgsql-hackers@lists.postgresql.org; Mon, 16 Mar 2026 19:19:13 +0000 Received: by mail-ot1-x334.google.com with SMTP id 46e09a7af769-7d750eeaec3so1746188a34.0 for ; Mon, 16 Mar 2026 12:19:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773688750; x=1774293550; 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=lzutUkpsvENUegW86E0Vq/2xgD194XrH7S8dyaXjnu8=; b=QJQYiM1TFpR33hyRr9d0eynjxrQGjFTzkb8Sw775zIHvtx3RJht/19lrGLoAJOrb7M mGXaNxSi9ciMWZSpfSJp9mtpDZVfMcorRs9g0wT0f4E8SNlMdNW0koP7JrImQqt64xOv Pka4LXXT9AQN8Sll5n2SexCdkBw5cW70UDYGhI1Lm5JVBdb2QqIBUBP98KkLufcqfKwx JOvp+Jz64NZmbP2eeaZDHTiBjzvvZE54PgQhHj3IUOG4+pox/NSr5RvVkYPXgb/zmzy0 TMwjcIBrZrnGWp40a/O1D9S94xbeIJuTm3FafUWSJHtMRE88IUeTJ/uN+AgI6JF+fI1E +mWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773688750; x=1774293550; 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=lzutUkpsvENUegW86E0Vq/2xgD194XrH7S8dyaXjnu8=; b=H0MGCxsWySGHFCnT1HtWhKO9JJlc4zZiWbQlavLlEiXmPF4w+9rvTdE2euyK4WMRJ+ 7SHjzn8V0T+IareMc4NRLdx6lQRz3zTheZArtCk5oqIdqAZHAx5Pm4MTUweikI67AprW NDmZvAUqxTVz7XwxNJXyz/GP1LA7nN4VSUe0veCyk6yY2brn/bC5pTLoWKIxsd8Kxrp6 1Iew4s0Y+em0qVEpSm8o0g5TxUbF5fsjTfaguChVnul9OxFItqOlXqeVfLi+CL02ICEn 6ZQecK+xbeUQJdCvds6RITtndGg4+1Et+jupsb4xVFIxeZZl1xb77rjiaabBgTs2Yxsi fLrQ== X-Forwarded-Encrypted: i=1; AJvYcCWI79ADmYm0W73BpEdA7RpTJKeRfaT1xzGeO6PMUan4Aoh6fMWbJrACQUbuPMqJhMg9cCATwLv8qHMBQv7c@lists.postgresql.org X-Gm-Message-State: AOJu0Yz9B9GHGshn1fDAaMgoOqev5sCiAl36gPG1vfkirVWTvoiRpf1N /fzUz7Y5ZDqCtoU1h5qR8KBvOPhUHh/3apGJ7ZkBDTadA3ms7iYFn6emhfKd5A== X-Gm-Gg: ATEYQzwCWAX6GSVWsGoHf0xsb9QqEaroULesgXpqaVnREY9kHw+Gs9mS/4pqdz18pKE 73vdY++lCKcjeujUxbfTAsvQOxP+tZ0/GFPO9Z9dyIW+DX4tsUpJjHTcpsk0xvnvoFvXvursFNV x2iAawAKDe0WO1l3cr8FbBuswxZSx3sImclLdTH/hhHtjK+amW6tUaGsvoMl6uJKNPy0yg4NcFM YbglgeKW2cTqJEdDaS9VOuJ/ZtzPQ6MX5G9MnGLhTYznFCftXAvbm7kRzUQ2/1uEdKBSaEck4K9 rsPKcOz3GxTaLTBokWraDKIcX2dkvmPOm03neSRrMB7p6phRLJtWNX87Otkm+eaP13mA5Yvr1Uw CPFHYi54O51BcOPcfryVXYjTaBYNIaCS/9pej2NTST60DSihXDpEJi14d/O4ZPGbzzAfBMWxmKG RtTBbNrytZh4qmovoBuc4aW5wLIIdIIVqwSoS5uyallknNoQ7J91bEppNmLJqhwvCk/TxmT5Ynl xVs0OdJKs9xwhdFWao538XGjHFuJCrE X-Received: by 2002:a05:6830:4c07:b0:7d7:54d5:c6f8 with SMTP id 46e09a7af769-7d78250c8cemr9765894a34.17.1773688750054; Mon, 16 Mar 2026 12:19:10 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d76ac8d43esm14111534a34.10.2026.03.16.12.19.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 12:19:09 -0700 (PDT) Date: Mon, 16 Mar 2026 14:19:07 -0500 From: Nathan Bossart To: Corey Huinker Cc: Sami Imseih , pgsql-hackers@lists.postgresql.org Subject: Re: Add starelid, attnum to pg_stats and leverage this in pg_dump Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="tOwyRy8JMBwx/S6s" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --tOwyRy8JMBwx/S6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Mar 14, 2026 at 05:13:19PM -0400, Corey Huinker wrote: > "_stable", nice name choice. Rebasing was nonzero but just barely. Thanks. Here is what I have staged for commit for the next patch in the series. > CREATE VIEW pg_stats WITH (security_barrier) AS > SELECT > - nspname AS schemaname, > - relname AS tablename, > - attname AS attname, > + n.nspname AS schemaname, > + c.relname AS tablename, > + a.attrelid AS tableid, > + a.attname AS attname, > + a.attnum AS attnum, I didn't see why we needed to change the lines for the existing columns, so I left those parts out. > CREATE VIEW pg_stats_ext WITH (security_barrier) AS > SELECT cn.nspname AS schemaname, > c.relname AS tablename, > + s.stxrelid AS tableid, > sn.nspname AS statistics_schemaname, > s.stxname AS statistics_name, > + s.oid AS statid, I went with "statistics_id" to match the naming scheme. > CREATE VIEW pg_stats_ext_exprs WITH (security_barrier) AS > SELECT cn.nspname AS schemaname, > c.relname AS tablename, > + s.stxrelid AS tableid, > sn.nspname AS statistics_schemaname, > s.stxname AS statistics_name, > + s.oid AS statid, > pg_get_userbyid(s.stxowner) AS statistics_owner, > - stat.expr, > + expr.expr, > + 0 - expr.ordinality AS expr_attnum, I left the expr_attnum stuff out. It seems to make this patch quite large and complicated, we don't plan to use it for the pg_dump patch, and I'm not sure about showing users a "synthetic attnum" that seems to have no other point of reference. Would this information be useful in pg_dump somewhere? I'm curious to hear more about the intent. > CREATE VIEW stats_import.pg_stats_stable AS > - SELECT schemaname, tablename, attname, inherited, null_frac, avg_width, > + SELECT schemaname, tablename, attname, attnum, inherited, null_frac, avg_width, I didn't see much value in adding attnum here given the size of the changes to the expected output it produces. > + tableid oid > + (references pg_attribute.attrelid) While we might be pulling the OID from pg_attribute in the view, we seem to point to the true origin for these reference notes elsewhere, so I changed it to pg_class.oid here. > + tableid oid > + (references pg_statistic_ext.stxrelid) ... and here. > + tableid oid > + (references pg_statistic_ext.stxrelid) ... and here. -- nathan --tOwyRy8JMBwx/S6s Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=v9-0001-Add-OIDs-and-attribute-numbers-to-pg_stats-and-fr.patch