New instances of Postgres, e.g. upgrades, maintenance, etc. may appear to have performance issues due to a cold cache.
To mitigate cold cache issues on a new Postgres instance:
If using a manual upgrade, e.g. a follower changeover, before the unfollow & promote step, use
pg_prewarmon the follower to help make sure important portions of the dataset are cached in the OS and PostgreSQL's buffer caches.
If using the
addons:upgrademethod you could run
pg_prewarmas soon as the new instance is active, as the replacement follower instance isn't accessible by the customer prior to the maintenance being run.
In addition, run common queries to help rebuild the Postgres buffer cache - On top of using
pg_prewarm, if there are any query statements in particular that you know run frequently, running it yourself will help ensure that the relevant blocks are loaded into cache.
Full documentation can be found in the Postgres documentation for
pg_prewarm but at its simplest you can pre-warm your core tables with:
select * from pg_prewarm('<tablename>');