This page describes how you can use the AlloyDB for PostgreSQL index advisor with Query Insights.
You can use the index advisor with Query Insights to view index advisor recommendations and create recommended indexes to improve query performance. To learn more about the index advisor, see Index advisor overview.
You can use Gemini in Databases assistance to help you monitor and troubleshoot your AlloyDB resources. For more information, see Monitor and troubleshoot with Gemini assistance.
To learn how to use the index advisor to view and query recommendations as a table, or to request an on-demand analysis and report, see Use the index advisor.
Before you begin
To access the Query Insights dashboard, enable access to AlloyDB in your Google Cloud project.
Required roles
To use the AlloyDB index advisor, you need permissions to do the following:
- To access index recommendations, you need permissions to access the AlloyDB Query Insights dashboard.
- To edit the index advisor settings, you need permissions to update AlloyDB instances.
To get these permissions, ask your administrator to grant you one of the following roles:
- Basic viewer (
roles/viewer
) - Database Insights viewer (
roles/databaseinsights.viewer
)
For more information about granting roles, see Manage access.
Disable index advisor recommendations
To disable index advisor recommendations, follow these steps:
In the Google Cloud console, go to the Clusters page.
From the list of clusters and instances, click an instance.
Click Query Insights.
Click Edit settings.
Disable the index advisor recommendations by deselecting Enable recommendations. Index advisor recommendations are enabled by default.
Change the refresh frequency for index advisor recommendations
To change the refresh frequency, follow these steps:
In the Google Cloud console, go to the Clusters page.
From the list of clusters and instances, click an instance.
Click Query Insights.
Click Edit settings.
Increase or decrease the refresh frequency for index advisor recommendations. The default refresh frequency is every 24 hours.
View and filter the index advisor recommendations
In the Google Cloud console, go to the Clusters page.
From the list of clusters and instances, click an instance.
Click Query Insights. The index advisor recommendations are displayed in the Recommendations column of the Top dimensions by database load table.
(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 Clusters page.
From the list of clusters and instances, click an instance.
Click Query Insights.
In the Top dimensions by database load table, 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 Clusters page.
From the list of clusters and instances, click an instance.
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 Clusters page.
From the list of clusters and instances, click an instance.
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 the index advisor to view and query recommendations as a table, or to request an on-demand analysis and report.
- Learn how AlloyDB helps make smart indexes.