---
title: Monitor active queries
description: View and analyze running queries in your Lakebase Postgres database.
canonical_url: https://docs.databricks.com/gcp/en/oltp/projects/active-queries
---

# Monitor active queries

Monitor active queries in your Lakebase Postgres project to track running queries, identify performance bottlenecks, and analyze query execution in real time.

## <a id="view-active-queries" />View active queries

1. From the Lakebase App, select your project.
2. In the sidebar, select a branch.
3. Go to **Monitoring**.
4. Select the **Active queries** tab.

![Query performance view](https://docs.databricks.com/gcp/en/images/oltp/active-queries.png)

The **Active queries** view displays up to 100 currently running queries for the selected branch. Select the **Compute**, **Database**, and **Role** from the dropdowns, then use the **Refresh** button to update the list with the latest active queries.

This view queries the `pg_stat_activity` Postgres system view to show real-time query activity.

### Understanding the Active queries view

The **Active queries** table displays the following information for each running query:

* **PID:** The process ID of the Postgres backend executing the query. This unique identifier can be used to track or terminate specific queries if needed.
* **Duration:** The elapsed time the query has been running. Click the column header to sort queries by duration to identify long-running operations.
* **Query:** The SQL statement being executed. This shows the actual query text, which can help you identify performance issues or unexpected database activity.

## <a id="pg-stat-activity" />About pg\_stat\_activity

The **Active queries** view is powered by the `pg_stat_activity` Postgres system view, which is available in Lakebase Postgres by default. To run custom queries against the data collected by `pg_stat_activity`, you can use the [SQL Editor](https://docs.databricks.com/gcp/en/oltp/projects/sql-editor.md) or any Postgres client, such as `psql`.

For details on `pg_stat_activity`, see [pg\_stat\_activity](https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW) in the PostgreSQL documentation.

> [!NOTE]
>
> The `pg_stat_activity` system view only shows currently running queries. After a query completes, it no longer appears in the **Active queries** view.

## <a id="additional-resources" /> Additional resources

* [Monitor query performance](https://docs.databricks.com/gcp/en/oltp/projects/query-performance.md)
* [Monitor with pg\_stat\_statements](https://docs.databricks.com/gcp/en/oltp/projects/pg-stat-statements.md)
* [Connect to your project](https://docs.databricks.com/gcp/en/oltp/projects/connect.md)
