Re: Statistics Import and Export - Mailing list pgsql-hackers

From Corey Huinker
Subject Re: Statistics Import and Export
Date
Msg-id CADkLM=f9CDaTFg=mvurE4o4X14wxes-T8=QP0oKRmK+swJcY9Q@mail.gmail.com
Whole thread Raw
In response to Re: Statistics Import and Export  (Jeff Davis <pgsql@j-davis.com>)
Responses Re: Statistics Import and Export
List pgsql-hackers
On Mon, Feb 24, 2025 at 1:54 PM Jeff Davis <pgsql@j-davis.com> wrote:
On Mon, 2025-02-24 at 13:47 -0500, Corey Huinker wrote:
> There doesn't seem to be any way around it, but it will
> slightly complicate the dump-ing side of things, in that we need to
> either:
>
> a) switch to attnums for index expressions and keep attname calls for
> everything else.

The only stats for indexes are on expression columns, so AFAICT there's
no difference between the above description and "use attnums for
indexes and attnames for tables". Either way, I agree that's the way to
go.

That's true now, but may not be in the future, like if we started keeping separate stats for partial indexes.
 

We certainly want attnames for tables to keep it working reasonably
well for cases where the user might be doing something more interesting
than a binary upgrade, as you point out. But attribute numbers for
indexes seem much more reliable: an index with a different attribute
order is a fundamentally different index.

Sadly, that attnum isn't available in pg_stats, so we'd have to reintroduce the joins to pg_namespace and pg_class to get at pg_attribute, at least for indexes.

 

pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Statistics Import and Export
Next
From: Jacob Brazeal
Date:
Subject: Re: Experimental tool to explore commitfest patches