Re: Optional skipping of unchanged relations during ANALYZE?

From: VASUKI M <vasukianand0119(at)gmail(dot)com>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Robert Treat <rob(at)xzilla(dot)net>, Ilia Evdokimov <ilya(dot)evdokimov(at)tantorlabs(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, Christoph Berg <myon(at)debian(dot)org>
Subject: Re: Optional skipping of unchanged relations during ANALYZE?
Date: 2026-02-16 12:19:53
Message-ID: CAE2r8H4EE9wTwfoykooJpyL1qZZweJoRdm0x2OBHeRd+riOMWg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

On Fri, Feb 13, 2026 at 11:51 PM Corey Huinker <corey(dot)huinker(at)gmail(dot)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 Content-Type Size
v5-0001-ANALYZE-add-MISSING_STATS_ONLY-option.patch text/x-patch 11.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nazir Bilal Yavuz 2026-02-16 12:22:24 Re: Improve docs syntax checking and enable it in the meson build
Previous Message Reshmithaa 2026-02-16 11:54:34 Re: Crash related to Shared Memory