i have logical replication setup on AWS RDS from a PG 9.5 primary to a PG 12.3 read replica via AWS DMS. (fyi the replica session_replication_role is set to "replica".)
query plans are not optimized on the PG 12.3 read replica and even basic queries run slowly without taking advantage of indexes. normally this is easily fixed by running "vacuumdb analyze".
question: is it safe to run analyze on the read replica? or should i run it on the master and it will propagate?
That should be no problem, since it modifies the table physically, but not logically.
However, I would only gather statistics with vacuumdb --analyze-only
. Running VACUUM
is seldom needed to improve query performance, and is uses way more resourcesthan ANALYZE
.