Chapter 29. Monitoring Database Activity

Table of Contents

29.1. Standard Unix Tools
29.2. The Cumulative Statistics System
29.2.1. Statistics Collection Configuration
29.2.2. Viewing Statistics
29.2.3. pg_stat_activity
29.2.4. pg_stat_replication
29.2.5. pg_stat_replication_slots
29.2.6. pg_stat_wal_receiver
29.2.7. pg_stat_recovery_prefetch
29.2.8. pg_stat_subscription
29.2.9. pg_stat_subscription_stats
29.2.10. pg_stat_ssl
29.2.11. pg_stat_gssapi
29.2.12. pg_stat_archiver
29.2.13. pg_stat_io
29.2.14. pg_stat_bgwriter
29.2.15. pg_stat_wal
29.2.16. pg_stat_database
29.2.17. pg_stat_database_conflicts
29.2.18. pg_stat_all_tables
29.2.19. pg_stat_all_indexes
29.2.20. pg_statio_all_tables
29.2.21. pg_statio_all_indexes
29.2.22. pg_statio_all_sequences
29.2.23. pg_stat_user_functions
29.2.24. pg_stat_slru
29.2.25. Statistics Functions
29.3. Viewing Locks
29.4. Progress Reporting
29.4.1. ANALYZE Progress Reporting
29.4.2. CLUSTER Progress Reporting
29.4.3. COPY Progress Reporting
29.4.4. CREATE INDEX Progress Reporting
29.4.5. VACUUM Progress Reporting
29.4.6. Base Backup Progress Reporting
29.5. Dynamic Tracing
29.5.1. Compiling for Dynamic Tracing
29.5.2. Built-in Probes
29.5.3. Using Probes
29.5.4. Defining New Probes

A database administrator frequently wonders, What is the system doing right now? This chapter discusses how to find that out.

Several tools are available for monitoring database activity and analyzing performance. Most of this chapter is devoted to describing PostgreSQL's cumulative statistics system, but one should not neglect regular Unix monitoring programs such as ps, top, iostat, and vmstat. Also, once one has identified a poorly-performing query, further investigation might be needed using PostgreSQL's EXPLAIN command. Section 14.1 discusses EXPLAIN and other methods for understanding the behavior of an individual query.