Preview
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of the Service Specific Terms. You can process personal data for this feature as outlined in the Cloud Data Processing Addendum, subject to the obligations and restrictions described in the agreement under which you access Google Cloud. Pre-GA features are available "as is" and might have limited support. For more information, see the launch stage descriptions.
This document describes how you can use AI assistance in Cloud SQL to troubleshoot slow queries in Cloud SQL. You can use the AI assistance capabilities of Cloud SQL and Gemini Cloud Assist to investigate, analyze, obtain recommendations, and finally implement those recommendations to optimize your queries in Cloud SQL.
Before you beginTo troubleshoot slow queries with AI assistance, do the following:
Required roles and permissionsFor the roles and permissions required to troubleshoot slow queries with AI assistance, see Observe and troubleshoot with AI.
Use AI assistanceTo use AI assistance with troubleshooting your slow queries, go to the Query insights dashboard for your Cloud SQL instance in Google Cloud console.
Top queries tableYou can start troubleshooting slow queries with AI assistance in the Top queries table section of the Query insights dashboard.
Cloud SQL can help you identify which queries are performing slower than average during a specific detection time period. After you select a time range in the Query insights dashboard, Cloud SQL checks whether any queries are performing slower than average by using a detection time period of 24 hours before the end of your selected time range.
When you adjust the time range filter of the Database load chart, or any other filter such as database or user, Cloud SQL refreshes the Top queries table and reruns anomaly detection based on the new list of queries and an updated detection time period.
When Cloud SQL detects an anomaly, Cloud SQL performs baseline performance analysis for your query after you click Analyze latency. Cloud SQL maps the metrics during the anomaly to the slow query and searches for situations that might have caused the slow performance. If Cloud SQL finds a potential situation, then it lets you view the evidence for the situation. Finally, Cloud SQL provides recommendations to fix and optimize your query performance.
To troubleshoot slow queries in the Top queries table in the Query insights dashboard, do the following:
In the Google Cloud console, go to the Cloud SQL Instances page.
If no queries display Analyze latency next to Avg Execution Time, then the reason might be one of the following:
You can also troubleshoot a slow query with AI assistance from the Query details page.
In the Google Cloud console, go to the Cloud SQL Instances page.
Using AI assistance, you can analyze and troubleshoot the details of your query latency.
In the Analyzing query latency page, you can view following details for your query and the text of your query:
The page also provides a latency chart that shows P50, P95, and P99 latency values over the selected time period. P50 shows you median latency where 50% of query users are experiencing high latency and 50% are experiencing lower latency. Similarly, the P95 and P99 lines show you that 95% and 99% of query users experience the indicated query latencies. For P95, 5% are experiencing a higher latency while for P99, only 1% are experiencing a higher latency.
You can see the specific time period when a significant increase in query latency occurred.
Analysis time periodThe analysis time period consists of the 24 hours that occur before the end of the time range that you select in the Database load chart of the Query insights dashboard or the Query details page. Cloud SQL uses this time period to compare baseline metrics with the metrics retrieved during the time period of the anomaly.
On the Query details page, if Cloud SQL has detected an anomaly with the query, then after you select the query from the Query insights dashboard, Cloud SQL performs a baseline performance analysis for the query using the last 24 hours from the end of the anomaly. If Cloud SQL hasn't detected an anomaly with the query and runs anomaly detection on the query again, then Cloud SQL uses 48 hours before the end of the selected time range as the performance baseline for the analysis time period.
Detected anomaly periodThe detected anomaly period represents a time period when Cloud SQL finds an anomalous change in query performance. Cloud SQL uses the baseline performance measured for the query during the analysis time period.
If Cloud SQL detects multiple anomalies for a query within a selected time period, then Cloud SQL uses the last detected anomaly.
SituationAfter you start your investigation, Cloud SQL analyzes your query, any historical data, and tries to identify an underlying situation that might explain the slower performance of your query over the selected time period.
For example, one situation for why your query is slow might be identified as Change in data volume.
In identifying this particular situation, Cloud SQL has detected an anomalous increase in data volume for this query. Cloud SQL also lists other possible situations where no anomalies are detected, so you can eliminate them as possible root causes.
EvidenceFor each situation, Cloud SQL provides a list of evidence to support the finding. Cloud SQL bases evidence on metrics gathered from the instance, the database, and historical runs of the query.
The evidence presented for each situation reflects any anomaly that Cloud SQL detects for the query within the detection time period. Cloud SQL defines an anomaly as when a metric surpasses certain thresholds or meets specific criteria.
In this example, to support the situation of a Change in data volume, you might see the following pieces of evidence:
You might also see evidence that supports typical or non-anomalous query performance, such as:
Evidence of standard query execution can help you decide which recommendation might be better for you to implement.
RecommendationsBased on all of the situations analyzed, Cloud SQL provides you with one or more actionable recommendations to help remediate the problems with your slow query performance. Cloud SQL presents the recommendations with a cost-benefit analysis so you can make an informed decision on whether to implement the recommendation.
For example, you might receive the following recommendation:
country
to improve the performance of this query.To implement this recommendation, do the following:
CREATE INDEX
command into Cloud SQL Studio to create the index. For more information about running SQL commands in Cloud SQL Studio, see Manage your data using Cloud SQL Studio.If you want to continue troubleshooting or get more assistance with query performance, then you can also open Gemini Cloud Assist. For more information, see Observe and troubleshoot with AI assistance.
What's nextRetroSearch 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