Report post #14 in Everything slow after pg_upgrade from 16 to 17
For anyone arriving here now: 18 keeps most planner stats through pg_upgrade. You still want vacuumdb --all --analyze-in-stages --missing-stats-only, the release notes have details.
Programming discussion