[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-05 UTC。"],[],[],null,["# Use the Spanner index advisor\n\nThis page describes the Spanner index advisor and how you can view and\napply its index recommendations. The index advisor is available for\nGoogleSQL-dialect databases and PostgreSQL-dialect databases.\n\nThe Spanner index advisor analyzes your queries to recommend new\nor altered indexes that can improve your query performance. You can view the\nindex advisor's recommendations in the Google Cloud console using either of the\nfollowing approaches:\n\n- Run a query and view its [query execution plan](/spanner/docs/query-execution-plans)\n- Use the Spanner [Query insights dashboard](/spanner/docs/using-query-insights)\n\nTo view the `CREATE INDEX` and `ALTER INDEX` recommendations, you can\nuse the Google Cloud console.\n\nFor more information about Spanner indexes, see\n[Secondary indexes](/spanner/docs/secondary-indexes).\n\nLimitations\n-----------\n\nSpanner index advisor has the following limitations:\n\n- Only provides `CREATE INDEX` and `ALTER INDEX` recommendations. Doesn't\n provide `DROP INDEX` recommendations for existing indexes.\n\n- An index recommendation is only shown if it provides a noticeable performance\n benefit.\n\n- If you are a [fine-grained access control](/spanner/docs/fgac-about) user or if you don't\n have DDL access, you can't execute index recommendation DDL statements. You\n can copy and save the recommendation.\n\nUse the query execution plan\n----------------------------\n\nTo view and apply index advisor recommendations from a query's execution plan,\nfollow these steps.\n\n### View recommendations\n\nTo view the query execution plan, run a query in the Google Cloud console:\n\n1. Go to the Spanner **Instances** page in\n Google Cloud console.\n\n [Go to Instances](https://console.cloud.google.com/spanner/instances)\n2. Select the instance that contains the database that you want to query.\n\n3. Select the name of the database you want to query.\n\n4. In the navigation menu, click **Spanner Studio**.\n\n5. Open a new SQL editor tab.\n\n6. In the editor pane, enter your SQL query.\n\n7. Click **Run**.\n\n8. After the query has finished running, to see the query execution plan, click\n the **Explanation** tab.\n\n The information panel shows detailed information about the query. If\n Spanner determines that a new or altered index can improve\n your query performance, then an index recommendations card is displayed.\n9. To view the index recommendation DDL statement, in the **Index recommendation**\n card, click **View details** to view the index.\n\n### Apply recommendations\n\nThe Spanner index recommendation provides complete `CREATE INDEX`\nand `ALTER INDEX` DDL statements for recommended indexes.\n\nTo apply the index advisor's recommendation, copy and run the index advisor's\nDDL statement into the Spanner Studio editor exactly as presented.\n\n1. In the **Index recommendation** pane, select the checkbox next to the DDL\n statements that you want to copy.\n\n2. Click **Copy to new tab**.\n\n3. In the new Spanner Studio editor tab, run the copied DDL statement.\n\nUse the Query insights dashboard\n--------------------------------\n\nTo view and apply index advisor recommendations from the Query insights\ndashboard, follow these steps.\n\n### View recommendations\n\n1. Go to the Spanner **Instances** page in\n Google Cloud console.\n\n [Go to Instances](https://console.cloud.google.com/spanner/instances)\n2. Select the name of the instance containing the database you want to query.\n\n3. Select the name of the database you want to query.\n\n4. In the navigation menu, click **Query insights**.\n\n5. View the **TopN queries and tags** table.\n\n The table shows a **Recommendation** column. If Spanner\n determines that a new or altered index can improve your query performance,\n then an index recommendation is displayed. To view what this looks\n like in the Google Cloud console, see\n [Identify a potentially problematic query or request tag](/spanner/docs/using-query-insights#filter-db-load).\n6. To view the index recommendation DDL statement, click **Index recommendation**.\n\n### Apply recommendations\n\nThe Spanner index recommendation provides complete `CREATE INDEX`\nand `ALTER INDEX` DDL statements for recommended indexes.\n\nTo apply the index advisor's recommendation, copy and run the index advisor's\nDDL statement into the Spanner Studio editor exactly as presented.\n\n1. In the **Index recommendation** pane, select the DDL statements you want to\n copy.\n\n Spanner generates recommendations for TopN queries every 12\n hours for the TopN queries executed in the preceding 12 hours. The\n **Index recommendation** pane displays a record of how long ago it was last\n refreshed.\n\n2. Click **Copy to Spanner Studio** .\n Google Cloud console displays the **Spanner Studio** editor.\n\n If you are a fine-grained access control user, you don't see the **Copy to\n Spanner Studio** button, and you can't run the DDL statement.\n3. In the Spanner Studio editor, run the copied DDL statement.\n\nWhat's next\n-----------\n\n- Learn more about Spanner [secondary indexes](/spanner/docs/secondary-indexes).\n\n- Learn more [SQL best practices](/spanner/docs/sql-best-practices).\n\n- Learn how to [Troubleshoot performance regressions](/spanner/docs/troubleshooting-performance-regressions)."]]