log_statement_sample_rate
to control which statements are logged based on duration.-1
(disabled). Set to a value like 100ms
(for OLTP) or 1000ms
(for data warehouses) to sample slow queries. Combine with log_statement_sample_rate = 0.1
to log approximately 10% of qualifying statements. Adjust based on your log volume tolerance and monitoring needs.-1
(disabled). Set to 100ms
for OLTP systems or 1000ms
for analytical workloads. Start with a higher value and gradually decrease until you find the right balance between capturing meaningful performance data and managing log volume. Avoid setting to 0
in production as it will log all statements regardless of duration.error
is appropriate for most production environments. For development and testing, consider warning
to capture more potential issues. For highly sensitive production systems, you might use log
or higher to reduce noise while still capturing critical errors.error
) produce less log output but may miss important diagnostic information. Lower severity levels (like debug1
) provide extensive detail but can generate substantial log volume.warning
is reasonable for production systems. Use error
for high-volume production environments where log size is a concern. For development and troubleshooting, consider info
or debug1
to get more detailed information. Adjust based on your specific monitoring needs and log storage capacity.10000ms
(10 seconds) is reasonable for most environments. Increase to 30000ms
for very large databases with long recovery times. Decrease to 5000ms
for debugging startup issues. Set to 0
to disable progress logging if not needed.log_min_duration_sample
threshold that will actually be logged, enabling statistical sampling of slow queries.log_min_duration_sample
to implement intelligent sampling of slow queries, preventing log overload in high-volume environments while still providing representative performance data. By logging only a fraction of qualifying statements, you can maintain visibility into performance trends without excessive log growth.1.0
(log all qualifying statements). For high-volume systems, set to 0.1
or 0.2
to log 10-20% of slow queries. Adjust based on your query volume and monitoring requirements. Higher values provide more complete data but increase log volume.0.0
(disabled). Set to 0.01
or 0.001
for production systems to capture a small sample of complete transactions. For debugging specific issues, temporarily increase to higher values. Be cautious with higher settings as they can significantly increase log volume.Start your journey toward a healthier PostgreSQL with pghealth.
You can explore all features immediately with a free trial β no installation required.
π Start Free Trial