postgresqlamazon-aurora

Why run manual ANALYZE against Aurora Postgres post upgrade?


I upgraded 19 RDS clusters without running Analyze and ran into zero issues. On the 20th upgrade, 2 hours later our DB reads were experiencing massive latency. After getting in touch with AWS support, they told me I had to run Analyze; against each db manually (now I see it in their upgrade documentation).

This solved the issue, but why is it only an issue for this RDS instance and not others? I'm using the default default:aurora-postgresql-13 group so shouldn't auto vacuum have run which would have run Analyze; automatically? What am I missing?


Solution

  • why is it only an issue for this RDS instance and not others?

    Actually applies to Postgres upgrades in general. pg_upgrade instructs to update statistics after upgrading:

    15. Statistics

    Because optimizer statistics are not transferred by pg_upgrade, you will be instructed to run a command to regenerate that information at the end of the upgrade. You might need to set connection parameters to match your new cluster.

    Cloud services like to be in control and keep their users in the dark (a bit too much sometimes). So you don't get to see this when Amazon runs pg_upgrade behind the curtains (and whatever additional magic they need, especially with forks like Aurora that uses a custom storage system).

    Note, not everybody wants or even needs to update statistics for (all) table columns. Some workloads are not sensitive to column statistics. So it's not a forced step.