5000
is reasonable for most environments. For busy systems with diverse query patterns, increase to 10000-20000
. Monitor pg_stat_statements
view regularly and adjust if you notice frequent query eviction. Calculate memory usage as approximately max * 200 bytes
per tracked statement.on
for production environments to maintain historical performance data. Be aware that enabling this feature requires periodic writes to disk, which may have a minor I/O impact. Ensure adequate disk space for the statistics file, typically located in the data directory.top
(top-level statements only) is recommended for most production environments. Use all
for comprehensive debugging when investigating performance issues within functions. Avoid none
unless you're experiencing significant performance overhead from tracking.on
for development and performance tuning environments. For production, evaluate the overhead—typically minimal—and enable if query planning performance is a concern. The additional data provides valuable insights for optimizing complex queries.on
is useful for monitoring overall database activity. Consider setting to off
if you have frequent utility commands that are filling the pg_stat_statements memory and causing frequently executed SELECT/INSERT/UPDATE/DELETE queries to be evicted. For most environments, keeping it enabled provides valuable operational insights.Start your journey toward a healthier PostgreSQL with pghealth.
You can explore all features immediately with a free trial — no installation required.