Stay organized with collections Save and categorize content based on your preferences.
This page describes how to monitor and troubleshoot the queries that are active in your database. Monitoring these queries can help identify causes of system latency and high CPU usage.
On the Query insights dashboard, you can view a summary of active transactions and a list of transactions with associated query and statistics. The transactions are displayed by the transaction start time. If there is a large number of queries running, then the results might be limited to a subset of total queries.
Before you beginTo monitor active queries, you can use either Cloud SQL Enterprise edition or Cloud SQL Enterprise Plus edition.
To terminate a session or a long-running transaction in active queries, you must use Cloud SQL Enterprise Plus edition for your Cloud SQL for PostgreSQL instance.
For more information about Cloud SQL editions, see Introduction to Cloud SQL editions.
Required roles and permissionsTo get the permissions that you need to view active queries, ask your administrator to grant you the following IAM roles on the project that hosts the Cloud SQL instance:
roles/cloudsql.viewer
)roles/databaseinsights.viewer
)roles/cloudsql.editor
)roles/databaseinsights.operationsAdmin
)For more information about granting roles, see Manage access to projects, folders, and organizations.
These predefined roles contain the permissions required to view active queries. To see the exact permissions that are required, expand the Required permissions section:
Required permissionsThe following permissions are required to view active queries:
databaseinsights.activeQueries.fetch
databaseinsights.activitySummary.fetch
You might also be able to get these permissions with custom roles or other predefined roles.
Enable active queriesTo enable active queries for a Cloud SQL Enterprise edition instance, do the following:
In the Google Cloud console, go to the Cloud SQL Instances page.
To enable active queries for a Cloud SQL Enterprise Plus edition instance, do the following:
In the Google Cloud console, go to the Cloud SQL Instances page.
To be able to terminate a session or long-running transaction in active queries, you must use query insights for Cloud SQL Enterprise Plus edition.
Disable active queriesTo disable active queries on a Cloud SQL Enterprise edition or Cloud SQL Enterprise Plus edition instance, do the following:
In the Google Cloud console, go to the Cloud SQL Instances page.
To view your active queries, complete the following steps:
In the Google Cloud console, go to the Cloud SQL Instances page.
To open the Overview page of an instance, click the instance name.
Do one of the following to display the Query insights dashboard:
Click the Active queries tab.
From here, you can modify the query information that appears in the Longest running transactions table:
Summary scorecard of all active queries: provides an overview of all the active queries by displaying the total connections based on the following parameters:
You can view a list of top long-running transactions with normalized active queries on the Query insights dashboard. A normalized active query removes sensitive data and returns a digest. The digest is the same for different values used in the following example:
Regular queries
select * from test_table where id=1;
select * from test_table_where id=2;
Digest or normalized query
select * from test_table where id=?;
A query that runs in different sessions is displayed as different entries on the dashboard.
View top longest running transactionsThe Longest running transactions table on the Query insights dashboard contains the following columns:
Column name Description Process ID Unique identifier of the connection or thread ID. Query SQL query text. Status Status of the connection. Session duration Duration of the last session running. Transaction duration Duration of the active transaction running. Query duration Duration of the last query running in that transaction. Wait event type Wait event type of the occurring wait event. Wait event Occurring wait event. Database Database name on which this connection is running. Application name Application name on which this connection is running. User name Name of the user connected to the database. Client address Specific IP address of the client that sent a query. Action Contains a link for terminating a transaction.The display is refreshed every 60 seconds automatically.
Terminate a processTo terminate a process or long-running transaction in active queries, you must use Cloud SQL Enterprise Plus edition and enable both Active query analysis and query insights for Cloud SQL Enterprise Plus edition.
Long running operations can take longer to terminate.
To terminate a query or transaction, complete the following steps:
If the system successfully terminates the query or transaction, then a success message appears. The system also performs a rollback if needed.
Note: If Terminate isn't available, then you might have insufficient IAM permissions. For more information, see Before you begin. What's nextExcept as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-07-02 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4