# postgresql.conf session_preload_libraries = 'auto_explain' auto_explain.log_min_duration = '3s'
Или
postgres=# LOAD 'auto_explain';
postgres=# SET auto_explain.log_min_duration = 0;
postgres=# SET auto_explain.log_analyze = true;
postgres=# SELECT count(*)
           FROM pg_class, pg_index
           WHERE oid = indrelid AND indisunique;
В итоге в /var/log/postgresql будет план запроса