When PostgreSQL operates normally, it tries to cache important data. The shared_buffers variable is important as it defines the size of the cache managed by PostgreSQL. The problem now is this: if you restart the database server, all the cache managed by PostgreSQL will be lost. Maybe the operating system will still have some data to reduce the impact on disk wait, but in many cases, this won't be enough. The solution to the problem is called the pg_prewarm extension:
test=# CREATE EXTENSION pg_prewarm;CREATE EXTENSION
The extension deploys a function that allows us to explicitly prewarm the cache whenever it is needed:
test=# \xExpanded display is on. test=# \df *prewa*List of functions-[ RECORD 1 ]-------+-------------------------------------------------------- ...