PostgreSQL – Logging Collector Blocking Auto Explain Output

explainlogspostgresql

Postgres 10.4

Postgres 9.6

Problem on both versions

I want to collect postgresql slow queries plan, so I added to my postgresql.conf setting from documentation

session_preload_libraries = 'auto_explain'

auto_explain.log_min_duration = '5s'

in the end of config

But also we use

logging_collector = true

and if logging_collector is on, no explain in logs

If logging_collector commented, I can see plan of queries
How can I use both options?

UPDATE:
We had about 10 queries runs more than 5 seconds, but finally with grep we found only one output in log with explain instead of all plans
How it could be only one record was logged? neither all plans, no no plans only one explain

Best Answer

Works for me.

Could it be that the other long queries were run over existing connections (perhaps with a connection pooler) for which the session_preload_libraries has not taken effect?