Skip to content

Commit

Permalink
sql: add computed columns to crdb_internal persisted sql stats views
Browse files Browse the repository at this point in the history
Follows #99042, #99148.

This commit adds the following computed columns to both
crdb_internal.statement_statistics_persisted and
crdb_internal.transaction_statistics_persisted views:
-execution_count
-service_latency
-cpu_sql_nanos
-contention_time
-total_estimated_execution_time
-p99_latency

These computed columns are indexed in the system
tables from which these views are created.

Epic: None

Release note: The crdb_internal.statement_statistics_persisted
and crdb_internal.transaction_statistics_persisted views now
include computed columns, to optimize the performance of
frequently-queried expressions.
  • Loading branch information
ericharmeling committed Mar 22, 2023
1 parent aa0b102 commit c0d95d7
Show file tree
Hide file tree
Showing 3 changed files with 492 additions and 109 deletions.
28 changes: 26 additions & 2 deletions pkg/sql/crdb_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6393,7 +6393,13 @@ CREATE VIEW crdb_internal.statement_statistics_persisted AS
statistics,
plan,
index_recommendations,
indexes_usage
indexes_usage,
execution_count,
service_latency,
cpu_sql_nanos,
contention_time,
total_estimated_execution_time,
p99_latency
FROM
system.statement_statistics`,
resultColumns: colinfo.ResultColumns{
Expand All @@ -6409,6 +6415,12 @@ CREATE VIEW crdb_internal.statement_statistics_persisted AS
{Name: "plan", Typ: types.Jsonb},
{Name: "index_recommendations", Typ: types.StringArray},
{Name: "indexes_usage", Typ: types.Jsonb},
{Name: "execution_count", Typ: types.Int},
{Name: "service_latency", Typ: types.Float},
{Name: "cpu_sql_nanos", Typ: types.Float},
{Name: "contention_time", Typ: types.Float},
{Name: "total_estimated_execution_time", Typ: types.Float},
{Name: "p99_latency", Typ: types.Float},
},
}

Expand Down Expand Up @@ -6623,7 +6635,13 @@ CREATE VIEW crdb_internal.transaction_statistics_persisted AS
node_id,
agg_interval,
metadata,
statistics
statistics,
execution_count,
service_latency,
cpu_sql_nanos,
contention_time,
total_estimated_execution_time,
p99_latency
FROM
system.transaction_statistics`,
resultColumns: colinfo.ResultColumns{
Expand All @@ -6634,6 +6652,12 @@ CREATE VIEW crdb_internal.transaction_statistics_persisted AS
{Name: "agg_interval", Typ: types.Interval},
{Name: "metadata", Typ: types.Jsonb},
{Name: "statistics", Typ: types.Jsonb},
{Name: "execution_count", Typ: types.Int},
{Name: "service_latency", Typ: types.Float},
{Name: "cpu_sql_nanos", Typ: types.Float},
{Name: "contention_time", Typ: types.Float},
{Name: "total_estimated_execution_time", Typ: types.Float},
{Name: "p99_latency", Typ: types.Float},
},
}

Expand Down
Loading

0 comments on commit c0d95d7

Please sign in to comment.