다음을 통해 공유


PGSQLQueryStoreRuntime 테이블에 대한 쿼리

Azure Portal에서 이러한 쿼리를 사용하는 방법에 대한 자세한 내용은 Log Analytics 자습서를 참조하세요. REST API는 쿼리를 참조 하세요.

임계값을 초과하는 쿼리 실행

정의된 임계값보다 오래 걸리는 쿼리를 식별합니다.

// Please change the threshold in milliseconds upon your requirements
// By default, entries are aggregated every 15 mins (see pg_qs.interval_length_minutes)
// PlanId is captured only if pg_qs.store_query_plans=ON
let MinQueryExecutionThresholdInMilliseconds=1000;
PGSQLQueryStoreRuntime
| where IsSystemQuery==false //excludes azure managed user
| where MeanExecDurationMs > MinQueryExecutionThresholdInMilliseconds
| project
    StartTime,
    EndTime,
    QueryId,
    PlanId,
    QueryType,
    UserId,
    DatabaseId,
    MeanExecDurationMs,
    MaxExecDurationMs,
    Calls,
    Rows
| order by MeanExecDurationMs desc, QueryId asc
| limit 100

가장 느린 쿼리

평균 실행 시간별로 가장 느린 상위 10개 쿼리를 식별합니다.

// PlanId is captured only if pg_qs.store_query_plans=ON
PGSQLQueryStoreRuntime
| where IsSystemQuery==false //excludes azure managed user
| summarize AvgMeanExecDuration=avg(MeanExecDurationMs),MaxExecDuration=max(MaxExecDurationMs) by QueryId, PlanId, QueryType, UserId, DatabaseId
| top 10 by AvgMeanExecDuration desc

쿼리 수

모든 쿼리의 실행 개수 추세를 식별합니다.

// By default, entries are aggregated in QueryStore every 15 mins (see pg_qs.interval_length_minutes)
// AgregationWindow was set to 15min, but you may modify it based on your needs, however should not be less than pg_qs.interval_length_minutes. 
let AgregationWindow=15m;
PGSQLQueryStoreRuntime
| where IsSystemQuery==false //excludes azure managed user
| summarize sum(Calls) by bin(EndTime,AgregationWindow)
| render columnchart