From 2c81026d24b39dd406f0b1497e7698c28dd5c676 Mon Sep 17 00:00:00 2001 From: maryliag Date: Thu, 23 Mar 2023 13:29:30 -0400 Subject: [PATCH] server: update sort of sql stats to new computed columns Part of #98624 To take advantage of the actual indexes created on the new persisted views, we need to use the computed columns. This PR updates the sort by column to use the new columns instead. Release note: None --- pkg/server/combined_statement_stats.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/server/combined_statement_stats.go b/pkg/server/combined_statement_stats.go index 18d65a9d633f..79ea60ecaf86 100644 --- a/pkg/server/combined_statement_stats.go +++ b/pkg/server/combined_statement_stats.go @@ -208,12 +208,12 @@ FROM crdb_internal.%s_statistics_persisted // Common stmt and txn columns to sort on. const ( - sortSvcLatDesc = `(statistics -> 'statistics' -> 'svcLat' ->> 'mean')::FLOAT DESC` - sortCPUTimeDesc = `(statistics -> 'statistics' -> 'execution_statistics' -> 'cpuSQLNanos' ->> 'mean')::FLOAT DESC` - sortExecCountDesc = `(statistics -> 'statistics' ->> 'cnt')::INT DESC` - sortContentionTimeDesc = `(statistics -> 'execution_statistics' -> 'contentionTime' ->> 'mean')::FLOAT DESC` - sortPCTRuntimeDesc = `((statistics -> 'statistics' -> 'svcLat' ->> 'mean')::FLOAT * - (statistics -> 'statistics' ->> 'cnt')::FLOAT) DESC` + sortSvcLatDesc = `service_latency DESC` + sortCPUTimeDesc = `cpu_sql_nanos DESC` + sortExecCountDesc = `execution_count DESC` + sortContentionTimeDesc = `contention_time DESC` + sortPCTRuntimeDesc = `total_estimated_execution_time DESC` + sortP99Desc = `p99_latency DESC` ) func getStmtColumnFromSortOption(sort serverpb.StatsSortOptions) string { @@ -225,7 +225,7 @@ func getStmtColumnFromSortOption(sort serverpb.StatsSortOptions) string { case serverpb.StatsSortOptions_EXECUTION_COUNT: return sortExecCountDesc case serverpb.StatsSortOptions_P99_STMTS_ONLY: - return `(statistics -> 'statistics' -> 'latencyInfo' ->> 'p99')::FLOAT DESC` + return sortP99Desc case serverpb.StatsSortOptions_CONTENTION_TIME: return sortContentionTimeDesc default: