[[["易于理解","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-05-07。"],[[["\u003cp\u003eAdvanced query insights features in AlloyDB for PostgreSQL provide real-time detection, troubleshooting, and prevention of database and query performance issues.\u003c/p\u003e\n"],["\u003cp\u003eThese features allow for in-depth analysis with near real-time query statistics, including correlation across dimensions like users, hosts, and databases, as well as detailed query execution plans.\u003c/p\u003e\n"],["\u003cp\u003eThe system offers prebuilt dashboards, visual query plans, and insights based on Google Cloud's security and privacy standards, enhancing problem identification and resolution.\u003c/p\u003e\n"],["\u003cp\u003eAdvanced query insights utilize an extension to record metrics and execution plans, which are stored in AlloyDB tables and Cloud Trace, respectively, with metrics available within 30 seconds of query completion.\u003c/p\u003e\n"],["\u003cp\u003eThe system has limitations such as the unavailability of metrics via Cloud Monitoring API, no support for client IP addresses, and the need to disable advanced query insights before creating secondary instances, alongside storage considerations.\u003c/p\u003e\n"]]],[],null,["# Advanced query insights features overview\n\nThis page describes advanced query insights features in AlloyDB for PostgreSQL. For information about setting up and using advanced query insights features, see [Improve query performance using advanced query insights features](/alloydb/docs/using-advanced-query-insights).\n\nAdvanced query insights features offer query performance diagnostics as\nwell as all of the features available in [standard query insights](/alloydb/docs/query-insights-overview).\n\nAdvanced query insights features let you detect, troubleshoot, and prevent database\nand query performance problems in near real time. Based on the previous seven\ndays of Query Insights data, you can monitor query performance at the\napplication level and trace the source of problematic queries across the\napplication stack by action, controller, framework, route, application, and\ndatabase driver. Advanced query insights features capture query\nplans for all queries and samples up to 20 query plans\nper minute.\n\nTo help you proactively identify and troubleshoot root causes of query\nperformance issues, advanced query insights features let you do the following:\n\n- Perform ad hoc analysis to diagnose difficult problems using near real-time query stats and correlation analysis across multiple dimensions like users, hosts, and databases.\n- View your query execution plan using complete SQL statements, along with accompanying comments. You can opt in to view comments associated with a query, where applicable.\n- Troubleshoot complex performance issues by analyzing telemetry, like wait events. A *wait event* is a component that causes a delay in processing a query-related operation. Wait event metrics, enabled by default, help you diagnose and debug performance issues for long-running queries and their associated wait times.\n- View [index advisor recommendations](/alloydb/docs/use-index-advisor-with-query-insights) about creating indexes.\n- Configure your query insight settings. For example, you can customize query lengths, enable wait event analysis, and store query comments and application tags. You can access historical and near real-time data.\n- Analyze data for up to a 30-day period for a long term performance view.\n\nBenefits of advanced query insights features\n--------------------------------------------\n\nThe following advanced query insights features are available to help you detect and\nfix query performance problems:\n\n- Prebuilt dashboards that help you identify query performance problems early and let you identify, diagnose, and resolve issues in a single page on the Google Cloud console.\n- Visual query plans that help you identify root causes and troubleshoot issues. You can trace the source of a problematic query with in-context, end-to-end application tracing.\n- Insights based on Google Cloud's enterprise security, privacy and compliance offerings, which might reduce operational overhead.\n- Application-centric monitoring and simplified performance diagnosis of applications built using object relational mappers (ORM). You can monitor database performance with an application-centric view by tagging queries with business logic. [Sqlcommenter](https://google.github.io/sqlcommenter/spec/), an open source library, auto-instruments your ORMs to help identify the application code causing performance problems.\n\nHow advanced query insights features work\n-----------------------------------------\n\nAdvanced query insights features are fully managed, which means you don't need to install\nor actively manage the feature.\n\nAdvanced query insights features load\nan extension that records query metrics and execution plans that are\nimplemented using hooks. The metrics are stored in AlloyDB\ntables, and normalized execution plans are stored in\n[Cloud Trace](/trace/docs).\n\nYou can access these metrics in\nthe AlloyDB Query Insights page of\nthe Google Cloud console. Metrics are expected to be available in\nadvanced query insights features within 30 seconds of query completion. Metrics are\nencrypted at rest in the same way as database storage.\n\nAdvanced query insights features store and display only normalized queries. All the\nconstant values from the query string are removed. Query comments are preserved\nonly on demand, it is an opt-in feature. Query plan traces don't collect and\nstore constant values.\n\n### Storage\n\nAdvanced query insights features store and display only normalized queries. All the\nconstant values from the query string are removed. Query plan traces don't\ncollect and store any constant values. By default, advanced query insights features don't collect tags information. If enabled at a later stage, they can be disabled\nfrom advanced query insights features per instance setting.\n\nThe **Query insights** dashboard provides four weeks of data. The storage\nrequirement for seven days' worth of data is approximately 36GB.\nAdvanced query insights features use up to 10 MB of RAM (shared memory). Metrics are\nexpected to be available in insights within 30 seconds of query completion. In\naddition, standard query insights metrics are available in system metrics in\nCloud Monitoring to keep the functionalities of the standard query insights\nintact. For\nmore information about the Cloud Monitoring system metrics retention policy,\nsee [Data retention](/monitoring/quotas#data_retention_policy).\n\nTraces from advanced query insights features are stored in Cloud Trace and have a 30-day\nretention period. For more information about the Cloud Trace data retention\npolicy, see\n[Quotas and limits](/trace/docs/quotas).\n\nLimitations\n-----------\n\n- The metrics exposed by advanced query insights features aren't available using a Cloud Monitoring API.\n- Client IP address support isn't available.\n- You cannot enable advanced query insights features on clusters with secondary instances. Before creating a secondary instance on a cluster, you must disable advanced query insights features on all the instances in the cluster.\n- AlloyDB stores query insights data for its primary and read pool instances for 30 days. Storing data for primary instances consumes about 180 GB and might increase based on the number of read pool nodes present in the cluster. The maximum consumed storage size is 700 GB.\n- You must [enable advanced query insights features](/alloydb/docs/using-advanced-query-insights#enable-advanced-query-insights) on a primary instance before enabling them on a read pool instance.\n- The query insights dashboard resets after you enable advanced query insights features. However, you can still access the standard query insights metrics using the [Metrics explorer UI](/monitoring/charts/metrics-explorer).\n\nWhat's next\n-----------\n\n- [Improve query performance using query insights](/alloydb/docs/using-advanced-query-insights).\n- Learn about [AlloyDB metrics](/monitoring/api/metrics_gcp_a_b#gcp-alloydb)."]]