[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-25。"],[[["\u003cp\u003eQuery insights is a tool for AlloyDB databases that helps detect, diagnose, and prevent query performance problems through self-service monitoring and diagnostics.\u003c/p\u003e\n"],["\u003cp\u003eThis tool allows users to monitor query performance at the application level and trace issues across the application stack, integrating with existing APM tools and Google Cloud services.\u003c/p\u003e\n"],["\u003cp\u003eThe query insights dashboard provides filters to view database load by various factors, such as user, database, IP address, time range, and various wait states, helping to identify performance bottlenecks.\u003c/p\u003e\n"],["\u003cp\u003eQuery insights uses SQL Commenter to instrument ORMs and tag queries, enabling application-centric monitoring and facilitating the identification of problematic code.\u003c/p\u003e\n"],["\u003cp\u003eQuery insights has no additional cost, uses minimal RAM, doesn't use any instance storage space, and is supported on all AlloyDB machine types and Google Cloud Platform regions.\u003c/p\u003e\n"]]],[],null,["# About query insights\n\nThis page gives an overview of the query insights tool. To start using the tool\nnow, see [Improve query performance by using query insights](/alloydb/docs/using-query-insights).\n\nQuery insights help you detect, diagnose, and prevent query performance problems for\nAlloyDB databases. They provide self-service, intuitive monitoring, and\ndiagnostic information that goes beyond detection to help you to identify the\nroot cause of performance problems.\n\nWith query insights, you can monitor performance at an application level and\ntrace the source of a problematic query across the application stack by model,\nview, controller, route, user, and host. The query insights tool can integrate\nwith your existing application monitoring (APM) tools and Google Cloud\nservices using open standards and APIs. This way, you can monitor and\ntroubleshoot query problems using your favorite tool.\n\nYou view metrics for queries on the query insights dashboard. The dashboard\nprovides a series of filters that help you view database load for queries\nby user, database, IP address, time range, CPU capacity, CPU and CPU wait, IO\nWait, and Lock Wait.\n\nBenefits of using query insights\n--------------------------------\n\nQuery insights provide monitoring and diagnostics that let you detect and fix\nquery performance problems. Query insights dashboards help you identify query\nperformance problems early and let you move from detection to resolution using a\nsingle interface. Built-in, visual query plans assist you in troubleshooting\nissues to find the root cause. You can also use in-context, end-to-end\napplication tracing to find the source of a problematic query.\n\nQuery insights let you tag queries with business logic that the query is\nassociated with, such as payment, inventory, business analytics, or shipping so\nthat you can monitor query performance from an application-centric perspective.\nAlso, query insights provide application-centric monitoring that helps you\ndiagnose performance problems for applications built using object-relational\nmappings (ORMs). The query insights tool uses [SQL Commenter](https://google.github.io/sqlcommenter/spec/),\nan open source library, to automatically instrument your ORMs. This\ninstrumentation helps you identify which application code is causing problems.\n\nQuery insights can integrate with your existing APM tools, letting you monitor\nand troubleshoot query problems using your favorite tool. Query insights\nsupport the [OpenCensus](https://opencensus.io/) and\n[OpenTelemetry](https://opentelemetry.io/) standards and makes the query metrics\nand traces data available for your APM tools through the [Google Cloud Observability](https://cloud.google.com/products/operations) API. Query insights integrate\nwith [Cloud Monitoring](https://cloud.google.com/monitoring), letting you\ncreate custom dashboards and alerts on query metrics or tags and receive\nnotifications using email, SMS, Slack, PagerDuty, and more.\n\nPricing\n-------\n\nThere is no additional cost for this feature. You can access one week of data on\nthe query insights dashboard. For API requests, see the Cloud Monitoring\n[Pricing](/stackdriver/pricing). Cloud Monitoring has a\ntier you can use at no additional cost.\n\nSecurity\n--------\n\nUsers who have access to the AlloyDB dashboard can access query insights\nmetrics on the query insights dashboard.\n\nQuery insights metrics are encrypted at rest.\n\nPrivacy\n-------\n\nQuery insights store and display only normalized queries. All the constant\nvalues from the query string are removed. Query plan traces don't collect or\nstore any constant values. By default, query insights collect IP addresses and\ntag information.\n\nPerformance\n-----------\n\nQuery insight's PostgreSQL extension records query metrics and execution plans\nimplemented using postgres hooks. The metrics, and execution plans, are stored\nas a postgres table in a shared memory table. By avoiding using expensive Disk\nI/O operations, query insights are always on, and their performance overhead is\nexpected to be small. Query insights use 12 MB of RAM for a default query\nstring size of 1024 bytes. RAM usage increases with an increase in the query\nstring size. Metrics are expected to be available in query insights within\nminutes of query completion.\n\nStorage\n-------\n\nQuery insights don't occupy any storage space in your AlloyDB instance\nstorage space. Metrics are stored in system metrics in\n[Cloud Monitoring](/monitoring/docs/monitoring-overview).\nIt's important to review the\n[Cloud Monitoring data retention policy](/monitoring/quotas#data_retention_policy).\n\nQuery insights traces are stored in [Cloud Trace](/trace/docs/overview).\nIt's important to review the\n[Cloud Trace data retention policy](/trace/docs/quotas#trace_retention_periods).\n\nCompatibility\n-------------\n\nQuery insights are supported on all AlloyDB machine types\nand available on all Google Cloud Platform regions.\n\nLimitations\n-----------\n\nThe limitations of query insights are as follows:\n\n- When client IP address tracking is enabled and a high number of clients, for example, exceeding 100, send traffic to an instance, query insights capture the client addresses that contribute to the highest cumulative execution time. Consequently, statistics related to other client addresses might be omitted.\n\n- When client IP address tracking is enabled, changes in client address traffic can lead to a temporary gap in metrics, because it takes time for the new top client addresses to be exported. For example, a client restart or recreation, such as a Kubernetes pod sending traffic from different machines, might cause this gap, depending on your architecture.\n\nWhat's Next\n-----------\n\n- [Improve query performance using query insights](/alloydb/docs/using-query-insights)\n- [AlloyDB metrics](/monitoring/api/metrics_gcp_a_b#gcp-alloydb)"]]