All we need is an easy explanation of the problem, so here it is.
I am working on AWS RDS Postgres v9.6, and also v14. I noticed that in our
shared_preload_libraries parameter, we have
pg_stat_statement included. I don’t understand why that needs to be there.
In the Postgres docs, it says this:
The module must be loaded by adding pg_stat_statements to shared_preload_libraries in postgresql.conf, because it requires additional shared memory. This means that a server restart is needed to add or remove the module.
However, several other extensions are already built in – for example we use
hstore. These do not need to be in
shared_preload_libraries. Why does
pg_stat_statement behave differently?
I think shedding light on this would help me (and hopefully others) better understand how built in libraries work, especially as regards the
shared_preload_libraries parameter. The docs don’t seem to say enough on this topic, or else I don’t know where to find it.
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
pg_stat_statements stores its data in a shared memory segment, and PostgreSQL only allows you to create shared memory segments when the server is started. So the extension has to be loaded at the time the server is started.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂