User Tools

Site Tools


middleware:postgresql

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
middleware:postgresql [2017/01/05 16:43]
ap Run a SQL script
middleware:postgresql [2018/07/30 13:30] (current)
ap Performance
Line 64: Line 64:
 psql -v ON_ERROR_STOP=Yes -1 -w -a -f ${SCRIPT} $PGDATABASE > ${SCRIPT}.log 2>&1 && echo OK || echo ERROR psql -v ON_ERROR_STOP=Yes -1 -w -a -f ${SCRIPT} $PGDATABASE > ${SCRIPT}.log 2>&1 && echo OK || echo ERROR
 </​code>​ </​code>​
 +
 +===== Performance =====
 +==== Enable statement statistics ====
 +  * Put in ''​postgresql.conf'':​
 +<​code>​
 +shared_preload_libraries = '​pg_stat_statements'​
 +</​code>​
 +  * Restart postgres
 +  * Enable the extension:
 +<​code>​
 +CREATE EXTENSION pg_stat_statements;​
 +</​code>​
 +
 +==== Show slowest queries ====
 +<​code>​
 +SELECT * FROM pg_stat_statements ORDER BY total_time DESC;
 +</​code>​
 +
 +See: [[https://​www.cybertec-postgresql.com/​en/​detecting-performance-problems-easily-in-postgresql]]
 +
 +==== Decode the EXPLAIN output ====
 +
 +[[https://​explain.depesz.com/​]]
  
middleware/postgresql.txt · Last modified: 2018/07/30 13:30 by ap

Informativa sui cookie