---
title: "Understand wait events | Database Observability documentation"
description: "Learn where queries spend time waiting for resources like locks, I/O, and CPU."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Understand wait events

Wait events show where your queries spend time waiting for resources instead of actively executing. Understanding wait events helps you identify resource contention, lock conflicts, and I/O bottlenecks that cause performance problems.

## What are wait events

When a query executes, it alternates between:

- **Active execution**: CPU is processing the query
- **Waiting**: Query is blocked, waiting for a resource

Wait events capture what the query is waiting for. High wait times indicate that queries are spending significant time blocked rather than executing.

## Why wait events matter

Wait events reveal performance problems that other metrics miss:

Expand table

| Problem                    | What metrics show   | What wait events reveal             |
|----------------------------|---------------------|-------------------------------------|
| Lock contention            | High query duration | Queries waiting for row/table locks |
| Disk I/O bottleneck        | Slow queries        | Queries waiting for disk reads      |
| Connection pool exhaustion | Timeouts            | Queries waiting for connections     |
| Shared buffer contention   | Memory pressure     | Queries waiting for buffer access   |

## Access wait events

To view wait events in Database Observability:

1. Navigate to **Database Observability** in Grafana Cloud.
2. In the Queries Overview, note the **Wait Events Duration** chart showing cumulative wait time.
3. Click a query to open its details.
4. Select the **Wait Events** tab for detailed analysis.

### Overview dashboard wait events

The Queries Overview shows a bar chart of cumulative wait event duration by category. This gives you a quick view of where queries spend the most time waiting.

The overview chart groups individual wait event types into high-level categories for easier visualization:

**PostgreSQL categories:**

Expand table

| Category         | Included wait event types                                                                                                                                                                                 |
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| **IO Wait**      | `IO`                                                                                                                                                                                                      |
| **Lock Wait**    | `Lock`, `LWLock`, `Activity`, `Extension`, `InjectionPoint`, `IPC`, `Timeout`, `BufferPin`. This broad category covers heavyweight locks, lightweight locks, and other synchronization or blocking waits. |
| **Network Wait** | `Client`                                                                                                                                                                                                  |

**MySQL categories:**

Expand table

| Category         | Included wait event patterns                    |
|------------------|-------------------------------------------------|
| **IO Wait**      | `wait/io/file/*`, `wait/io/table/*`             |
| **Lock Wait**    | `wait/lock/*`, `wait/synch/*`, `wait/io/lock/*` |
| **Network Wait** | `wait/io/socket/*`                              |

### Wait Events tab

The Wait Events tab shows a time series chart of wait events for a specific query. Use the dropdown to switch between four views:

- **Cumulative duration of wait events (by group)**: Stacked bars showing total wait time for each category (IO Wait, Lock Wait, Network Wait) over time. This is the default view.
- **Cumulative duration of wait events (breakdown)**: Stacked bars broken down by individual wait event name (for example, `Lock:relation`, `IO:DataFileRead`), giving a more granular picture.
- **Number of wait events**: Count of wait events by category over time.
- **Wait events duration (by group)**: Average duration per event by category over time.

## Use wait events for diagnosis

This workflow shows how to use wait events to narrow down the source of latency.

### Workflow: Diagnose slow queries

1. **Identify affected queries**: In the Queries Overview, find queries with high wait event duration.
2. **View wait events tab**: Click the query and open the Wait Events tab.
3. **Compare views**: Use the dropdown to switch between cumulative duration, event count, and average duration to understand the wait pattern.
4. **Drill into duration of wait events (breakdown)**: Switch to the breakdown view to see which specific wait events contribute the most time.
5. **Take action**: Apply fixes based on the dominant wait event type (refer to the tips below).

The following table lists common scenarios you may encounter:

Expand table

| Scenario                | Wait pattern                  | Action                                      |
|-------------------------|-------------------------------|---------------------------------------------|
| Database backup running | High I/O waits                | Schedule backups during low-traffic periods |
| Large transaction       | Lock waits increasing         | Break into smaller transactions             |
| Peak traffic            | Multiple wait types elevated  | Scale resources or optimize queries         |
| New deployment          | Lock waits on specific tables | Check for schema changes, new queries       |

## Tips for addressing wait events

Use these tips to address the most common wait event patterns.

### Lock contention

- Review transaction isolation levels
- Consider optimistic locking patterns
- Break long transactions into smaller units
- Check for deadlock patterns

### I/O contention

- Add indexes to reduce table scans
- Increase memory/buffer pools
- Review disk performance
- Consider read replicas for read-heavy workloads

### Buffer contention

- Tune shared buffer settings
- Review concurrent access patterns
- Consider connection pooling adjustments

## Related documentation

- [Examine query samples](/docs/grafana-cloud/monitor-applications/database-observability/investigate/examine-query-samples/): See when waits occurred
- [Analyze explain plans](/docs/grafana-cloud/monitor-applications/database-observability/investigate/analyze-explain-plans/): Understand query execution
- [Improve slow queries](/docs/grafana-cloud/monitor-applications/database-observability/optimize/improve-slow-queries/): Optimization workflow
- [MySQL configuration](/docs/grafana-cloud/monitor-applications/database-observability/reference/mysql-configuration/): `Performance Schema` setup
- [PostgreSQL configuration](/docs/grafana-cloud/monitor-applications/database-observability/reference/postgres-configuration/): `pg_stat_activity` access
- [Troubleshoot Database Observability](/docs/grafana-cloud/monitor-applications/database-observability/troubleshoot/): Resolve setup and configuration issues
