0Pricing
PostgreSQL Performance & Query Optimization · Lesson

Diagnosing Live Activity with pg_stat_activity

Learn to use the pg_stat_activity view to see what every connection is doing right now, find long-running and blocked queries, and safely cancel or terminate problem sessions.

Your Window into Live Sessions

The pg_stat_activity view has one row per server connection. It is the first place to look when the database feels slow or stuck, showing what each session is doing this instant.

The Key Columns

The most useful columns are:

  • pid: the backend process id
  • state: active, idle, idle in transaction
  • query: the current or last SQL text
  • wait_event: what the session is waiting on

All lessons in this course

  1. Using pg_stat_statements and pg_buffercache
  2. Logging Configuration for Analysis
  3. External Monitoring Tools Integration
  4. Diagnosing Live Activity with pg_stat_activity
← Back to PostgreSQL Performance & Query Optimization