쿼리 통계는 AlloyDB 데이터베이스의 쿼리 성능 문제를 감지하고 진단하고 방지하는 데 도움이 됩니다. 감지뿐 아니라 셀프서비스, 직관적인 모니터링, 진단 정보를 제공하여 문제의 근본 원인을 식별하는 데 도움이 됩니다.
쿼리 통계를 사용하면 애플리케이션 수준에서 성능을 모니터링하고 모델, 뷰, 컨트롤러, 경로, 사용자, 호스트별로 애플리케이션 스택에서 문제가 있는 쿼리의 소스를 trace할 수 있습니다. 쿼리 통계 도구는 개방형 표준 및 API를 사용하여 기존 애플리케이션 모니터링 (APM) 도구 및 Google Cloud서비스와 통합할 수 있습니다. 그러면 원하는 도구를 사용하여 쿼리 문제를 모니터링하고 해결할 수 있습니다.
쿼리 통계 대시보드에서 쿼리 측정항목을 확인합니다. 대시보드는 사용자, 데이터베이스, IP 주소, 시간 범위, CPU 용량, CPU 및 CPU 대기, IO 대기, 잠금 대기별로 쿼리에 대한 데이터베이스 로드를 볼 수 있는 일련의 필터를 제공합니다.
쿼리 통계 사용의 이점
쿼리 통계는 쿼리 성능 문제를 감지하고 해결할 수 있는 모니터링 및 진단을 제공합니다. 쿼리 통계 대시보드는 쿼리 성능 문제를 조기에 파악하고 단일 인터페이스를 사용하여 감지에서 해결까지 처리할 수 있도록 도와줍니다. 내장된 시각적 쿼리 계획은 근본 원인을 찾아 해결하는 데 도움이 됩니다. 컨텍스트 내 엔드 투 엔드 애플리케이션 추적을 사용하여 문제가 있는 쿼리의 소스를 찾을 수도 있습니다.
쿼리 통계를 사용하면 애플리케이션 중심의 관점에서 쿼리 성능을 모니터링할 수 있도록 쿼리에 연결된 비즈니스 로직(예: 결제, 인벤토리, 비즈니스 분석, 배송)으로 쿼리를 태그할 수 있습니다.
또한 쿼리 통계는 객체 관계형 매핑 (ORM)을 사용하여 빌드된 애플리케이션의 성능 문제를 진단하는 데 유용한 애플리케이션 중심 모니터링을 제공합니다. 쿼리 통계 도구는 오픈소스 라이브러리인 SQL Commenter를 사용하여 ORM을 자동으로 계측합니다. 이 계측을 통해 문제를 일으키는 애플리케이션 코드를 식별할 수 있습니다.
쿼리 통계는 기존 APM 도구와 통합할 수 있으므로 원하는 도구로 쿼리 문제를 모니터링하고 해결할 수 있습니다. 쿼리 통계는 OpenCensus 및 OpenTelemetry 표준을 지원하고 Google Cloud Observability API를 통해 APM 도구에 쿼리 측정항목과 추적 데이터를 사용할 수 있도록 해 줍니다. 쿼리 통계는 Cloud Monitoring과 통합되어 쿼리 측정항목 또는 태그에 대한 맞춤 대시보드와 알림을 만들고 이메일, SMS, Slack, PagerDuty 등을 사용하여 알림을 받을 수 있습니다.
가격 책정
이 기능은 추가 비용이 없습니다. 쿼리 통계 대시보드에서 1주일 분량의 데이터에 액세스할 수 있습니다. API 요청은 Cloud Monitoring 가격 책정을 참조하세요. Cloud Monitoring에는 추가 비용 없이 사용할 수 있는 등급이 있습니다.
보안
AlloyDB 대시보드에 대한 액세스 권한이 있는 사용자는 쿼리 통계 대시보드에서 쿼리 통계 측정항목에 액세스할 수 있습니다.
쿼리 통계 측정항목은 저장 상태에서 암호화됩니다.
개인 정보 보호
쿼리 통계는 정규화된 쿼리만 저장하고 표시합니다. 쿼리 문자열의 상수 값이 모두 삭제됩니다. 쿼리 계획 Trace는 상수 값을 수집하거나 저장하지 않습니다. 기본적으로 쿼리 통계는 IP 주소와 태그 정보를 수집합니다.
성능
쿼리 통계의 PostgreSQL 확장 프로그램은 postgres 후크를 사용하여 구현된 쿼리 측정항목 및 실행 계획을 기록합니다. 측정항목 및 실행 계획은 공유 메모리 테이블에 postgres 테이블로 저장됩니다. 고비용 디스크 I/O 작업 사용을 방지하면 쿼리 통계가 항상 사용 설정되며 성능 오버헤드가 미미합니다. 쿼리 통계는 기본 쿼리 문자열 크기인 1,024바이트에 12MB RAM을 사용합니다. 쿼리 문자열 크기가 증가하면 RAM 사용량이 증가합니다. 쿼리 완료 후 수분 내에 쿼리 통계에서 측정항목을 사용할 수 있습니다.
쿼리 통계는 모든 AlloyDB 머신 유형에서 지원되며 모든 Google Cloud 플랫폼 리전에서 사용할 수 있습니다.
제한사항
쿼리 통계의 제한사항은 다음과 같습니다.
클라이언트 IP 주소 추적이 사용 설정되어 있고 100개를 초과하는 많은 클라이언트가 인스턴스로 트래픽을 전송하는 경우 쿼리 통계는 누적 실행 시간이 가장 높은 클라이언트 주소를 캡처합니다. 따라서 다른 클라이언트 주소와 관련된 통계가 누락될 수 있습니다.
클라이언트 IP 주소 추적을 사용 설정하면 새 상위 클라이언트 주소가 내보내지는 데 시간이 걸리므로 클라이언트 주소 트래픽이 변경될 때 측정항목에 일시적인 격차가 발생할 수 있습니다. 예를 들어 아키텍처에 따라 다른 머신에서 트래픽을 전송하는 Kubernetes 포드와 같은 클라이언트 다시 시작 또는 재생성으로 인해 이 격차가 발생할 수 있습니다.
[[["이해하기 쉬움","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\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)"]]