이 페이지에서는 PostgreSQL용 AlloyDB의 고급 쿼리 통계 기능에 대해 설명합니다. 고급 쿼리 통계 기능 설정 및 사용에 대한 자세한 내용은 고급 쿼리 통계 기능을 사용하여 쿼리 성능 개선을 참고하세요.
고급 쿼리 통계 기능은 쿼리 성능 진단과 표준 쿼리 통계에서 제공되는 모든 기능을 제공합니다.
고급 쿼리 통계 기능을 사용하면 거의 실시간으로 데이터베이스 및 쿼리 성능 문제를 감지하고, 문제를 해결하고, 문제를 방지할 수 있습니다. 이전 7일간의 쿼리 통계 데이터를 기반으로 애플리케이션 수준에서 쿼리 성능을 모니터링하고 작업, 컨트롤러, 프레임워크, 경로, 애플리케이션, 데이터베이스 드라이버별로 애플리케이션 스택에서 문제가 있는 쿼리의 소스를 추적할 수 있습니다. 고급 쿼리 통계 기능은 모든 쿼리의 쿼리 계획을 캡처하고 분당 최대 20개의 쿼리 계획을 샘플링합니다.
쿼리 성능 문제의 근본 원인을 선제적으로 파악하고 해결할 수 있도록 고급 쿼리 통계 기능을 사용하면 다음 작업을 할 수 있습니다.
거의 실시간 쿼리 통계와 사용자, 호스트, 데이터베이스와 같은 여러 측정기준에 걸친 상관관계 분석을 사용하여 어려운 문제를 진단하기 위해 임시 분석을 실행합니다.
전체 SQL 문과 함께 주석을 사용하여 쿼리 실행 계획을 확인합니다. 해당하는 경우 쿼리와 연결된 댓글을 볼 수 있습니다.
대기 이벤트와 같은 원격 분석을 분석하여 복잡한 성능 문제를 해결합니다. 대기 이벤트는 쿼리 관련 작업의 처리를 지연시키는 구성요소입니다. 기본적으로 사용 설정되는 대기 이벤트 측정항목은 장기 실행 쿼리 및 관련 대기 시간의 성능 문제를 진단하고 디버깅하는 데 도움이 됩니다.
쿼리 통계 설정을 구성합니다. 예를 들어 쿼리 길이를 맞춤설정하고, 대기 이벤트 분석을 사용 설정하고, 쿼리 댓글과 애플리케이션 태그를 저장할 수 있습니다. 이전 데이터와 거의 실시간 데이터에 액세스할 수 있습니다.
장기적인 실적을 확인하기 위해 최대 30일 기간의 데이터를 분석합니다.
고급 쿼리 통계 기능의 이점
다음 고급 쿼리 통계 기능을 사용하여 쿼리 성능 문제를 감지하고 수정할 수 있습니다.
쿼리 성능 문제를 조기에 파악하고 Google Cloud 콘솔의 단일 페이지에서 문제를 식별, 진단, 해결할 수 있는 사전 제작된 대시보드
근본 원인을 파악하고 문제를 해결하는 데 도움이 되는 시각적 쿼리 계획 컨텍스트 내 엔드 투 엔드 애플리케이션 추적을 사용하여 문제가 있는 쿼리의 소스를 추적할 수 있습니다.
Google Cloud의 엔터프라이즈 보안, 개인 정보 보호, 규정 준수 제품을 기반으로 한 인사이트로 운영 오버헤드를 줄일 수 있습니다.
객체 관계형 매퍼 (ORM)를 사용하여 빌드된 애플리케이션의 애플리케이션 중심 모니터링 및 간소화된 성능 진단 비즈니스 로직으로 쿼리를 태그하여 애플리케이션 중심 뷰로 데이터베이스 성능을 모니터링할 수 있습니다.
오픈소스 라이브러리인 Sqlcommenter는 ORM을 자동으로 계측하여 성능 문제를 일으키는 애플리케이션 코드를 식별하는 데 도움이 됩니다.
고급 쿼리 통계 기능의 작동 방식
고급 쿼리 통계 기능은 완전 관리형이므로 기능을 설치하거나 적극적으로 관리할 필요가 없습니다.
고급 쿼리 통계 기능은 후크를 사용하여 구현된 쿼리 측정항목 및 실행 계획을 기록하는 확장 프로그램을 로드합니다. 측정항목은 AlloyDB 테이블에 저장되고 정규화된 실행 계획은 Cloud Trace에 저장됩니다.
Google Cloud 콘솔의 AlloyDB 쿼리 통계 페이지에서 이러한 측정항목에 액세스할 수 있습니다. 측정항목은 쿼리 완료 후 30초 내에 고급 쿼리 통계 기능에서 사용할 수 있습니다. 측정항목은 데이터베이스 스토리지와 동일한 방식으로 저장 상태에서 암호화됩니다.
고급 쿼리 통계 기능은 정규화된 쿼리만 저장하고 표시합니다. 쿼리 문자열의 상수 값이 모두 삭제됩니다. 쿼리 주석은 요청 시에만 보존되며 선택사항인 기능입니다. 쿼리 계획 추적은 상수 값을 수집하거나 저장하지 않습니다.
스토리지
고급 쿼리 통계 기능은 정규화된 쿼리만 저장하고 표시합니다. 쿼리 문자열의 상수 값이 모두 삭제됩니다. 쿼리 계획 추적은 상수 값을 수집하거나 저장하지 않습니다. 기본적으로 고급 쿼리 통계 기능은 태그 정보를 수집하지 않습니다. 나중에 사용 설정된 경우 인스턴스별 설정의 고급 쿼리 통계 기능에서 사용 중지할 수 있습니다.
쿼리 통계 대시보드에는 4주간의 데이터가 표시됩니다. 7일 간 데이터의 스토리지 요구사항은 약 36GB입니다.
고급 쿼리 통계 기능은 최대 10MB의 RAM (공유 메모리)을 사용합니다. 측정항목은 쿼리 완료 후 30초 내에 통계에서 사용할 수 있습니다. 또한 표준 쿼리 통계의 기능을 그대로 유지하기 위해 Cloud Monitoring의 시스템 측정항목에서 표준 쿼리 통계 측정항목을 사용할 수 있습니다. Cloud Monitoring 시스템 측정항목 보관 정책에 대한 자세한 내용은 데이터 보관을 참고하세요.
고급 쿼리 통계 기능의 트레이스는 Cloud Trace에 저장되며 보관 기간은 30일입니다. Cloud Trace 데이터 보관 정책에 대한 자세한 내용은 할당량 및 한도를 참고하세요.
제한사항
고급 쿼리 통계 기능에서 표시하는 측정항목은 Cloud Monitoring API를 사용하여 사용할 수 없습니다.
클라이언트 IP 주소 지원은 제공되지 않습니다.
보조 인스턴스가 있는 클러스터에서는 고급 쿼리 통계 기능을 사용 설정할 수 없습니다. 클러스터에서 보조 인스턴스를 만들기 전에 클러스터의 모든 인스턴스에서 고급 쿼리 통계 기능을 사용 중지해야 합니다.
AlloyDB는 기본 인스턴스 및 읽기 풀 인스턴스의 쿼리 통계 데이터를 30일 동안 저장합니다. 기본 인스턴스의 데이터를 저장하는 데는 약 180GB가 사용되며 클러스터에 있는 읽기 풀 노드 수에 따라 증가할 수 있습니다. 최대 사용 스토리지 크기는 700GB입니다.
읽기 풀 인스턴스에서 고급 쿼리 통계 기능을 사용 설정하려면 기본 인스턴스에서 먼저 고급 쿼리 통계 기능을 사용 설정해야 합니다.
고급 쿼리 통계 기능을 사용 설정하면 쿼리 통계 대시보드가 재설정됩니다. 하지만 측정항목 탐색기 UI를 사용하여 표준 쿼리 통계 측정항목에 액세스할 수는 있습니다.
[[["이해하기 쉬움","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-04(UTC)"],[[["\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)."]]