Re: Optional skipping of unchanged relations during ANALYZE? - Mailing list pgsql-hackers

From VASUKI M
Subject Re: Optional skipping of unchanged relations during ANALYZE?
Date
Msg-id CAE2r8H4EE9wTwfoykooJpyL1qZZweJoRdm0x2OBHeRd+riOMWg@mail.gmail.com
Whole thread
In response to Re: Optional skipping of unchanged relations during ANALYZE?  (Corey Huinker <corey.huinker@gmail.com>)
List pgsql-hackers

Hi all,

On Fri, Feb 13, 2026 at 11:51 PM Corey Huinker <corey.huinker@gmail.com> wrote:
A few notes:

- attnum variables can be of type AttrNumber
- The SearchSysCache3 lookup can't assume inh = false. Partitioned tables will ONLY have inh = true. Inheritance parents will have both.
- Same inh concerns for extended stats.
Done.

I am attaching v5 of the MISSING_STATS_ONLY patch.

The main changes are in how we detect existing statistics for inherited and partitioned tables.

Previously, the column stats check assumed stainherit = false in the syscache lookup. As Corey pointed out, that assumption is incorrect:

Partitioned tables only have stainherit = true.

Inheritance parents can have both true and false entries.

In this version, the column stats check now tries both cases (stainherit = false and stainherit = true) before concluding that stats are missing. A column is considered missing stats only if neither entry exists.

The same logic has been applied to extended statistics as well.

Other than this correction, the overall semantics of ANALYZE (MISSING_STATS_ONLY) remain unchanged:

Relations with at least one analyzable attribute or extended stats object lacking statistics are analyzed.

Relations with complete statistics are skipped.

Repeated runs converge toward a no-op once stats are fully populated.

Regression tests were updated and re-run after this change.

Please let me know if the inheritance handling now matches expectations, or if there are additional cases I should consider.

As discussed earlier, I will start a separate thread for the modified-stats behavior once this direction is settled.

Thanks again for the review and guidance.

Regards,
Vasuki M
C-DAC,Chennai
Attachment

pgsql-hackers by date:

Previous
From: Reshmithaa
Date:
Subject: Re: Crash related to Shared Memory
Next
From: Nazir Bilal Yavuz
Date:
Subject: Re: Improve docs syntax checking and enable it in the meson build