This page describes how you can use the Cloud SQL for SQL Server index advisor with query insights for Cloud SQL Enterprise Plus edition.
You can use the index advisor with query insights for Cloud SQL Enterprise Plus edition to view index advisor recommendations and create recommended indexes to improve query performance. To learn more about the index advisor, see Index advisor overview.
Before you begin
- Make sure you're using Cloud SQL for SQL Server 2019 or later.
- Enable query insights for Cloud SQL Enterprise Plus edition.
- Create a custom role with the following permissions. Then, grant the role to each user account that needs to use query insights.
Tasks | Roles | Permissions |
---|---|---|
View recommendations |
databaseinsights.viewer
|
databaseinsights.recommendations.query databaseinsights.resourceRecommendations.query
|
View recommendations |
cloudsql.viewer
|
N/A |
View and filter the index advisor recommendations
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- To open the Overview page of an instance, click the instance name.
- Click Query insights.
- Click Enable. The index advisor recommendations are displayed in the Recommendation column of the Queries tab of the Top dimensions by database load section.
- (Optional) To view only queries with CREATE INDEX recommendations, add a filter for Recommendation: Create Indexes.
View recommendations for a query
To view details of index recommendations for a specific query, follow these 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.
- Click Query insights.
- In the Top queries and tags section, click Queries.
- To learn recommendation details about a query, do one of the following:
- Click a query to learn more about recommendations for the selected
query, including the following information:
- Performance impact (high, medium, and low): The estimated query speed after all recommended indexes are created.
- Recommendations: Create index recommendations.
- Tables impacted: The number of tables that will be impacted when indexes are created.
- Additional estimated storage needed: The estimated storage size needed to create all the recommended indexes.
- Number of impacted queries: The total number of queries in the workload impacted by the index recommendations. An index may benefit multiple queries.
- Click Create Indexes for a specific query to learn detailed recommendations about creating indexes to improve query performance.
- Click a query to learn more about recommendations for the selected
query, including the following information:
View impacted queries
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- To open the Overview page of an instance, click the instance name.
- Click Query insights.
- In the Top dimensions by database load table, click Queries.
- Click Create indexes for a specific query.
- Click Show impacted queries.
- Click a query to learn details about the impacted query.
Create recommended indexes
-
In the Google Cloud console, go to the Cloud SQL Instances page.
- To open the Overview page of an instance, click the instance name.
- Click Query insights.
- In the Top dimensions by database load table, click Queries.
- Click Create Indexes for a specific query.
- Click Copy all index commands. The CREATE INDEX commands are copied to your clipboard.
- Connect to the primary instance on the command line.
To create the recommended indexes, run the commands that were copied to your clipboard, for example:
CREATE INDEX ON "public"."demo_order" ("customer_id");
What's next
- Learn how to use index advisor to view and query recommendations as a table, or to request an on-demand analysis and report.
- Learn more about index advisor