Tool: get_index_recommendations
Fetches index advisor suggestions to optimize performance for a requested AlloyDB instance. Supports requesting recommendations for specific databases and a list of query IDs. Returns index recommendations including SQL commands (CREATE INDEX), target schema, relation, and columns, estimated storage size, and predicted query performance improvements (current vs estimated execution duration).
The following sample demonstrate how to use curl to invoke the get_index_recommendations MCP tool.
| Curl Request |
|---|
curl --location 'https://databaseinsights.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "get_index_recommendations", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
Message for requesting index recommendations (including SQL commands, storage size, and query improvements) for specific databases and queries on the requested instance.
BatchQueryIndexRecommendationsRequest
| JSON representation |
|---|
{
"parent": string,
"fullResourceName": string,
"databaseQueryIds": [
{
object ( |
| Fields | |
|---|---|
parent |
Required. The name of the location where we request recommendations. Format: |
fullResourceName |
Required. Full resource path of the instance. Example: |
databaseQueryIds[] |
Required. The list of databases and associated query IDs for which recommendations are requested. |
DatabaseQueryIds
| JSON representation |
|---|
{ "database": string, "queryIds": [ string ] } |
| Fields | |
|---|---|
database |
Required. The database name for which the recommendations are requested. |
queryIds[] |
Optional. The list of query IDs for which the recommendations are requested in this database. |
Output Schema
Response message containing index recommendations (SQL commands, schema, relation, columns, estimated storage size) and query performance improvements (current vs estimated execution duration).
BatchQueryIndexRecommendationsResponse
| JSON representation |
|---|
{
"fullResourceName": string,
"databaseIndexRecommendations": [
{
object ( |
| Fields | |
|---|---|
fullResourceName |
The resource identifier from the request. |
databaseIndexRecommendations[] |
Recommendations and improvements grouped by database. |
DatabaseIndexRecommendation
| JSON representation |
|---|
{ "database": string, "indexRecommendations": [ { object ( |
| Fields | |
|---|---|
database |
The database name. |
indexRecommendations[] |
The list of suggested indexes for this database. |
recommendationTime |
The time at which these recommendations were generated. Uses RFC 3339, where generated output will always be Z-normalized and use 0, 3, 6 or 9 fractional digits. Offsets other than "Z" are also accepted. Examples: |
queryImprovements |
Performance improvements for specific queries, keyed by query_id. An object containing a list of |
IndexRecommendation
| JSON representation |
|---|
{ "sqlCommand": string, "schema": string, "relation": string, "columns": [ string ], "estimatedStorageSizeBytes": string, "impactedQueryIds": [ string ], "impactedQueriesCount": integer, "indexRecommendationId": string } |
| Fields | |
|---|---|
sqlCommand |
The SQL command to create the recommended index. |
schema |
The name of the schema for the recommended index. |
relation |
The name of the relation (table) for the recommended index. |
columns[] |
The column names to create the index on. |
estimatedStorageSizeBytes |
The estimated storage size of the recommended index in bytes. |
impactedQueryIds[] |
The list of impacted query IDs for the recommended index. |
impactedQueriesCount |
The number of impacted queries for the recommended index. |
indexRecommendationId |
A unique identifier for this recommendation, used to map improvements back to it. |
Timestamp
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be between -62135596800 and 253402300799 inclusive (which corresponds to 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z). |
nanos |
Non-negative fractions of a second at nanosecond resolution. This field is the nanosecond portion of the duration, not an alternative to seconds. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be between 0 and 999,999,999 inclusive. |
QueryImprovementsEntry
| JSON representation |
|---|
{
"key": string,
"value": {
object ( |
| Fields | |
|---|---|
key |
|
value |
|
QueryImprovement
| JSON representation |
|---|
{ "queryId": string, "indexRecommendationIds": [ string ], "currentTotalExecutionDuration": string, "estimatedNewTotalExecutionDuration": string } |
| Fields | |
|---|---|
queryId |
The ID of the query being improved. |
indexRecommendationIds[] |
The IDs of the IndexRecommendations that contribute to this improvement. |
currentTotalExecutionDuration |
The current total execution duration for this query. A duration in seconds with up to nine fractional digits, ending with ' |
estimatedNewTotalExecutionDuration |
The predicted total execution duration after applying the indexes. A duration in seconds with up to nine fractional digits, ending with ' |
Duration
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years |
nanos |
Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌