TeamGood Morning.As part of DB upgrade from EC2 - PGS - community Edn Ver 13.X to 14.XI followed steps of "pg_upgrade" and had executed the last step (post successful db migration)vacuumdb --analyze-in-stagesand later noticed an caveat
--analyze-in-stagesOnly calculate statistics for use by the optimizer (no vacuum), like
--analyze-only. Run three stages of analyze; the first stage uses the lowest possible statistics target (see default_statistics_target) to produce usable statistics faster, and subsequent stages build the full statistics.This option is only useful to analyze a database that currently has no statistics or has wholly incorrect ones, such as if it is newly populated from a restored dump or by
pg_upgrade. Be aware that running with this option in a database with existing statistics may cause the query optimizer choices to become transiently worse due to the low statistics targets of the early stages.How to overcome the issue to avoid "transiently worse"
Later, I too dida) vacuum(full,verbose,skip_locked) ... each table wise
b) analyze (verbose,skip_locked) .. each table wiseAny guidance