Re: Optional skipping of unchanged relations during ANALYZE?

From: Sami Imseih <samimseih(at)gmail(dot)com>
To: Robert Treat <rob(at)xzilla(dot)net>
Cc: VASUKI M <vasukianand0119(at)gmail(dot)com>, 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-01-25 17:23:39
Message-ID: CAA5RZ0t=fGScwGL9=_HJzXf3808-U4zqne+qAob6R2PYcj-9YA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> I agree with this, but I think it's more than just tables that have
>> not been analyzed.
>> What if a new column is added after the last (auto)analyze. Would we not want to
>> trigger an analyze in that case?
>>

> Well, I don't know that we are "triggering" anything, but this is
> definitely a case where we have "missing stats".

> When MISSING_STATS is passed, we attempt to analyze only tables that
> have missing stats, essentially implementing a version of
> --missing-stats-only

I also want to do add that the benefit of implementing a --missing-stats
fo ANALYZE is that the timestamps in pg_stat_all_tables are cleared on
crash recovery, but pg_statistic is obviously persistent. So it is
better to look directly there as --missing-stats-only does for vacuumdb.

unfortunately, this is not the case for n_mod_since_analyze, because that
does not survive. There is discussion about improving this situation
however [0].

[0] https://www.postgresql.org/message-id/20240607033806.6gwgolihss72cj6r@awork3.anarazel.de

--
Sami Imseih
Amazon Web Services (AWS)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2026-01-25 17:52:37 Re: Make copyObject work in C++
Previous Message Tom Lane 2026-01-25 17:14:03 Re: alignas (C11)