[[["わかりやすい","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,["# Analyze query performance statistics\n\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes how to use the Query insights dashboard\nto detect and analyze query performance.\n\nQuery insights overview\n-----------------------\n\nUse the Query insights dashboard to monitor metrics-related queries.\nBased on the metrics, you can identify the most frequently used queries and\nqueries with high latencies that might require optimization. Use the Query\ninsights dashboard to help you with:\n\n- **Query performance optimization**: identify queries with high latencies and that might need optimization.\n- **Query cost management**: discover high-cost queries and optimize them to reduce costs.\n- **Query stats monitoring**: track query stats over time.\n\n### Query insights data\n\nQuery insights includes data from the following API methods:\n\n- [`runQuery`](/datastore/docs/reference/data/rest/v1/projects/runQuery)\n- [`runAggregationQuery`](/datastore/docs/reference/data/rest/v1/projects/runAggregationQuery)\n\nYou can view data about the queries that use these methods for a given\nproject, database, and time duration ranging from 10 minutes to\n30 days. Data for queries with equivalent structures is captured under a single\nnormalized query.\n\nQuery insights returns the following information about a query:\n\n### Data granularity and retention\n\nData granularity depends on the duration specified:\n\n- 10 minute granularity for intervals up to 4 days ago\n- 1 hour granularity for intervals up to 30 days ago\n\nThe maximum data retention for Query insights is 30 days.\n10-minute data is stored for 4 days, and hourly data is stored for 30 days.\n\n### Limitations\n\n- Query insights data is delayed by one to two hours.\n\nPricing\n-------\n\nThere's no additional cost for Query insights.\n\nRequired roles\n--------------\n\n\nTo get the permission that\nyou need to view the Query insights dashboard,\n\nask your administrator to grant you the\n\n\n[Datastore Viewer](/iam/docs/roles-permissions/firestore#datastore.viewer) (`roles/datastore.viewer`)\nIAM role on your project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains the\n` datastore.insights.get`\npermission,\nwhich is required to\nview the Query insights dashboard.\n\n\nYou might also be able to get\nthis permission\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nView Query insights\n-------------------\n\nTo view query insights for a Firestore in Datastore mode database, open the database\n**Query insights** pane in the Google Cloud console.\n\n1. In the Google Cloud console, go to the **Databases** page.\n\n [Go to Databases](https://console.cloud.google.com/firestore/databases)\n2. From the list of databases, select a database.\n\n3. In the navigation menu, click **Query insights**.\n\n Use the **Load type** drop-down to find the top queries by either latency or\n number of read operations.\n\nWhat's next\n-----------\n\n- Use [query explain](/datastore/docs/query-explain-analyze) to improve query performance\n- [Monitor usage](/datastore/docs/understand-performance-monitoring)"]]