> I can't help but think that this SMART option is not as smart as it > should be to actually > be valuable. > > I agree that we should never skip a table that has never been > analyzed. My concern > is that n_mod_since_analyze == 0 is not very useful. > > IMO, for the purpose of ensuring that we never skip relations that have never > been analyzed, > checking last_analyze / last_autoanalyze being NULL seems sufficient and > reliable.
edba754f052 introduced --missing-stats-only for vacuumdb. Although this was intended for pg_upgrade, it does note in the commit message that "it might be useful in other situations" Perhaps, this is one of the situations. So, instead of a smart mode, maybe we should be thinking about an ANALYZE (missing_stats_only) option that follows what is done in vacuumdb; and will skip tables that don't need to be analyzed. Ultimately vacuumdb can just use this option. The criteria for tables missing stats is more comprehensive than a simple last_analyze / last_autoanalyze being NULL. A followup commit 984d7165dd also mentions: " For v19, perhaps we could introduce a simple, inexpensive way to discover which relations are missing statistics, such as a system function or view with similar privilege requirements to ANALYZE. Unfortunately, it is far too late for anything like that in v18. " What do you think? -- Sami Imseih Amazon Web Services (AWS)
