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 1vzfMU-001Ct7-2U for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Mar 2026 18:29:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vzfMS-000Raf-2u for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Mar 2026 18:29:49 +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 1vzfMS-000RaX-1u for pgsql-hackers@lists.postgresql.org; Mon, 09 Mar 2026 18:29:49 +0000 Received: from mail-dl1-x122e.google.com ([2607:f8b0:4864:20::122e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vzfMQ-00000001q81-3cMq for pgsql-hackers@lists.postgresql.org; Mon, 09 Mar 2026 18:29:48 +0000 Received: by mail-dl1-x122e.google.com with SMTP id a92af1059eb24-126ea4b77adso14821642c88.1 for ; Mon, 09 Mar 2026 11:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773080985; cv=none; d=google.com; s=arc-20240605; b=PmWoNMzH5Pl1k2XGOZlpqsFiyEdFQfgv+xBxUKJ70IyECGWOwZT899P7//OEur+bAf /PkmlolgDeV9HC8mknO+9BWMepHOnBHQ8yMMVnMhbZE6sG3Kk321W2g1gbYIHKeX+RE8 nnGXEekrQ2K0VeYAjJiCOS8RslAeWwnJ4rmD1DbbZQpdSJnattbnVlcOa3FOKvco9rtZ tEm495bI0viCw42OqV5dKuk7nnkECYAuRcucdSovqeV0PKUpbdK8P9nkRupSLVD++tV6 2qCPqTmSAuDGZEjl59t5Z+29RLQD6vMpKKXEdLLL8sTuWtMTJB/Z/csUDvNb4iLZKJoi VzSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=lGAZGfUqGgbZRDwI65yZH2OvAnDMyiOv84/p8WztTkA=; fh=OVHhSPg886GNcpzXWONSSo4MPRYGHvZ9nz2G76AcDig=; b=VeBPF40ivdVqZ6tIOqQdy74yX4pV+AACzrnsaO+4h/CJZ18LF7ZvdUJl1wTEUcKMiO j9ut14vldC+GRFQwMMUAN6+wtZPFiNCM7ghwqLUPOYkms6UhYtDOhcu9nCLP9XZ7zrG0 OycBECUkeXwlcrhQcW+0O7GJp3TlpNmWZbAhYt4LRGgYi8vc4FYUf4oKnyymORUgh/6v BUJXeO644RoynVCEpHpAQUxOKB+zDA21MUjQnOXrlHMpMO8eZeBiI3GOBJpemFxKD07f 5yYY619yKSkiqkqnQza50kB5vgpw8O4CoDRa4z3/fGX1UpEDKNruuYblRaNl3GR7xS4r y0fw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773080985; x=1773685785; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=lGAZGfUqGgbZRDwI65yZH2OvAnDMyiOv84/p8WztTkA=; b=g+ZAYypf6yNloYNE13ZJIzDMpL89ddXIreyXSguOhJK8EsPAFAncVSTMvSkkDNR4sH MqKaaQGgDm+r+jKimVCTfC16Fz8r3dpQHHC3XWAUDQuTBsxqSTQnGDBW5MC863KP1vCi fv7WHkA8a+7RQ90vVt2CPuNRl4oZkA9aUcdxVy4QTOOmGf2qKPrcpdo5Af6sjrK7OP4V CmjHjdwxgydh0ovjIsJFmwEZXSTsg4N3+1gPiEPg63HFzrZpi4RYL3JczKCxIDEje6x+ rQSio7cbB+CK7DHNGuDb/vcBlRs7gShpgZn800JrUvHhwbWdZLBmyYX4htFZNNFErtoM Ri+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773080985; x=1773685785; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lGAZGfUqGgbZRDwI65yZH2OvAnDMyiOv84/p8WztTkA=; b=f06gGjadU7y+t/Rc5B5hgBy6icpASoFSeYfrN4e3SruEVAgzptlz34KJfQwyPO2hfM 5bO9HfUcc0CDB5ByGj+NT1TFWOVb9mVLu36ovKGGkEE5FpSOP90J5GqNwiKBivsaR4wk sJPC9+YTOK9XMi5zbLcsCKQ4rmX3t+ya7DL148/+lrkvBYhSuqyX0l+jbvTSuM0Sj41L wsQwiNodLVWsIB9ca5OemQmcXlgHNLdU7EUVM+uvnpMmPKFR/mlJNNmLvrTkHfmBmMxG qL/Cw329bI5boWexCykQ8LH7UqaGur2GE0qJu8rkKES/ZiRWGkaLHVl5lDxGBZ319V4C UsOg== X-Forwarded-Encrypted: i=1; AJvYcCXGgLlp72vxDa+KruR9gdRrhS4SdPPF15RBQXyAr4x/1qulx/7+G0VvqU2IQNkFF2AXpjsMI+M5NNo5ileE@lists.postgresql.org X-Gm-Message-State: AOJu0Yx8wizgJgnd0WUEo0IH54K9SYDVAprYhfwpHYDpfFk9I4MiWUUt +GyB3S45tKr9DybnyAdvKncWd8Z9nZWzs+5oeGvrSkPAOsJ31jDLimCPI46P0UkpmpdkfnNcZ9A rgpHuwOZ6vOHlr37w4GgfI6WK8NqtEQ8= X-Gm-Gg: ATEYQzx5CrMlefhfYAgmEYMvKZu9CbYfntkpFgLw2nXjvO6b3bz//4lhuYrK+GP8+PW KffFGlIw6YcBF/Iuszn5luAYFVcld039Nt5EEIwuA/o3oOqK8j3M3uMd+VO2F+Xj6UF4/+2faSh xLBmyqfnWC4lyXWehLWDgLUUokiXuQ3OVh8FjWL8og0AKbassCVc40ZXwDgytw8yuQ46s20fT5/ D6BJWI72V3u5pRef3rWK6lTI9wV+WLz89ZZ4/5DoB+8DTMBsdfTgydqc1+pFV+rIK4xBbZjAbjb xYlnRZCDC7AgHZChWEc0/qrdURX2hhig6nK0vRBKAA8HU3hLGn8AS581N1nlvOviSkclVkSCwa8 Km83dwRO/BRF5mkkWCc/ry7tG X-Received: by 2002:a05:7022:60a9:b0:121:72bb:3cd7 with SMTP id a92af1059eb24-128c2da552fmr4376597c88.7.1773080984892; Mon, 09 Mar 2026 11:29:44 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Corey Huinker Date: Mon, 9 Mar 2026 14:29:32 -0400 X-Gm-Features: AaiRm53qJQD4adA4QYfFEqiRYXKIZsngUgS-itAEpDFIRu0o54jTVuXaldyrdUI Message-ID: Subject: Re: Add starelid, attnum to pg_stats and leverage this in pg_dump To: Nathan Bossart Cc: Sami Imseih , pgsql-hackers@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000433a09064c9b96a9" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000433a09064c9b96a9 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 9, 2026 at 11:51=E2=80=AFAM Nathan Bossart wrote: > On Mon, Mar 09, 2026 at 10:44:58AM -0500, Sami Imseih wrote: > >> Oh, a question I forgot to ask: why wouldn't we do the same thing for > >> pg_stats_ext and pg_stats_ext_exprs? > > > > [...] > > > > If we do add relid there, it will be for consistency only. > > It might be only for consistency for now, but it strikes me as something > that could be handy down the road (in which case it'd be nice to minimize > the number of versions that need a fallback). > > -- > nathan > You're both right. Currently, we fetch extended stats one at a time, thus there's no _immediate_ need to do so. But "why wait until there is a crisis" is solid reasoning and for that I had already coded up the change. I did have one small problem in that Michael Paquier had hoped that we could get the expr index (-1, -2, etc) on the expressions as that was something that we at least briefly thought we'd need for importing expression statistics. However the existing query uses a SELECT unnest(a), unnest(b) pattern in it, and WITH ORDINALITY is not allowed, and the workarounds I found seemed a bit tortured. Hence, I decided to leave that out so as not to distract from the now accepted patch, and with that out of the way I'll happily inflict that tortured SQL on y'all. --000000000000433a09064c9b96a9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, Mar 9, = 2026 at 11:51=E2=80=AFAM Nathan Bossart <nathandbossart@gmail.com> wrote:
On Mon, Mar 09, 2026 at 10:44:58AM -05= 00, Sami Imseih wrote:
>> Oh, a question I forgot to ask: why wouldn't we do the same th= ing for
>> pg_stats_ext and pg_stats_ext_exprs?
>
> [...]
>
> If we do add relid there, it will be for consistency only.

It might be only for consistency for now, but it strikes me as something that could be handy down the road (in which case it'd be nice to minimi= ze
the number of versions that need a fallback).

--
nathan

You're both right. Currently= , we fetch extended stats one at a time, thus there's no _immediate_ ne= ed to do so.

But "why wait until there is a crisis&q= uot; is solid reasoning and for that I had already coded up the change. I d= id have one small problem in that Michael Paquier had hoped that we could g= et the expr index (-1, -2, etc) on the expressions as that was something th= at we at least briefly thought we'd need for importing expression stati= stics. However the existing query uses a SELECT unnest(a), unnest(b) patter= n in it, and WITH ORDINALITY is not allowed, and the workarounds I found se= emed a bit tortured. Hence, I decided to leave that out so as not to distra= ct from the now accepted patch, and with that out of the way I'll happi= ly inflict that tortured SQL on y'all.=C2=A0
--000000000000433a09064c9b96a9--