Skip to content

Commit

Permalink
sql: rename cpuNanos to cpuSQLNanos
Browse files Browse the repository at this point in the history
Fixes cockroachdb#96238

This commit clarifies the name on statement and
transaction statistics tables to use `cpuSQLNanos`
instead of `cpuNanos`.

Release note (sql change): Update `cpuNanos` name to `cpuSQLNanos`
on `crdb_internal.statement_statistics` and `system.statement_statistics`
  • Loading branch information
maryliag committed Jan 30, 2023
1 parent eb9fe1b commit fd5d88b
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 54 deletions.
4 changes: 2 additions & 2 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ node_id table_id name parent_id expiration deleted
query ITTTTTIIITRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRBBTTTTT colnames
SELECT * FROM crdb_internal.node_statement_statistics WHERE node_id < 0
----
node_id application_name flags statement_id key anonymized count first_attempt_count max_retries last_error rows_avg rows_var idle_lat_avg idle_lat_var parse_lat_avg parse_lat_var plan_lat_avg plan_lat_var run_lat_avg run_lat_var service_lat_avg service_lat_var overhead_lat_avg overhead_lat_var bytes_read_avg bytes_read_var rows_read_avg rows_read_var rows_written_avg rows_written_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_nanos_avg cpu_nanos_var implicit_txn full_scan sample_plan database_name exec_node_ids txn_fingerprint_id index_recommendations
node_id application_name flags statement_id key anonymized count first_attempt_count max_retries last_error rows_avg rows_var idle_lat_avg idle_lat_var parse_lat_avg parse_lat_var plan_lat_avg plan_lat_var run_lat_avg run_lat_var service_lat_avg service_lat_var overhead_lat_avg overhead_lat_var bytes_read_avg bytes_read_var rows_read_avg rows_read_var rows_written_avg rows_written_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_sql_nanos_avg cpu_sql_nanos_var implicit_txn full_scan sample_plan database_name exec_node_ids txn_fingerprint_id index_recommendations

query ITTTIIRRRRRRRRRRRRRRRRRRRRRR colnames
SELECT * FROM crdb_internal.node_transaction_statistics WHERE node_id < 0
----
node_id application_name key statement_ids count max_retries service_lat_avg service_lat_var retry_lat_avg retry_lat_var commit_lat_avg commit_lat_var idle_lat_avg idle_lat_var rows_read_avg rows_read_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_nanos_avg cpu_nanos_var
node_id application_name key statement_ids count max_retries service_lat_avg service_lat_var retry_lat_avg retry_lat_var commit_lat_avg commit_lat_var idle_lat_avg idle_lat_var rows_read_avg rows_read_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_sql_nanos_avg cpu_sql_nanos_var

query IITTTTTTT colnames
SELECT * FROM crdb_internal.session_trace WHERE span_idx < 0
Expand Down
8 changes: 4 additions & 4 deletions pkg/cli/zip_table_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,8 +746,8 @@ var zipInternalTablesPerNode = DebugZipTableRegistry{
"max_disk_usage_var",
"contention_time_avg",
"contention_time_var",
"cpu_nanos_avg",
"cpu_nanos_var",
"cpu_sql_nanos_avg",
"cpu_sql_nanos_var",
"implicit_txn",
"full_scan",
"sample_plan",
Expand Down Expand Up @@ -783,8 +783,8 @@ var zipInternalTablesPerNode = DebugZipTableRegistry{
"max_disk_usage_var",
"contention_time_avg",
"contention_time_var",
"cpu_nanos_avg",
"cpu_nanos_var",
"cpu_sql_nanos_avg",
"cpu_sql_nanos_var",
},
},
"crdb_internal.node_transactions": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/roachpb/app_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (s *ExecStats) Add(other ExecStats) {
s.ContentionTime.Add(other.ContentionTime, execStatCollectionCount, other.Count)
s.NetworkMessages.Add(other.NetworkMessages, execStatCollectionCount, other.Count)
s.MaxDiskUsage.Add(other.MaxDiskUsage, execStatCollectionCount, other.Count)
s.CPUNanos.Add(other.CPUNanos, execStatCollectionCount, other.Count)
s.CPUSQLNanos.Add(other.CPUSQLNanos, execStatCollectionCount, other.Count)

s.Count += other.Count
}
6 changes: 3 additions & 3 deletions pkg/roachpb/app_stats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ message ExecStats {
// large sort where not all of the tuples fit in memory.
optional NumericStat max_disk_usage = 6 [(gogoproto.nullable) = false];

// CPUNanos collects the cumulative CPU time spent executing SQL operations in
// CPUSQLNanos collects the cumulative CPU time spent executing SQL operations in
// nanoseconds. Currently, it is only collected for statements without
// mutations that have a vectorized plan.
optional NumericStat cpu_nanos = 7 [(gogoproto.nullable) = false,
(gogoproto.customname) = "CPUNanos"];
optional NumericStat cpu_sql_nanos = 7 [(gogoproto.nullable) = false,
(gogoproto.customname) = "CPUSQLNanos"];

// Note: be sure to update `sql/app_stats.go` when adding/removing fields
// here!
Expand Down
16 changes: 8 additions & 8 deletions pkg/sql/crdb_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -1365,8 +1365,8 @@ CREATE TABLE crdb_internal.node_statement_statistics (
max_disk_usage_var FLOAT,
contention_time_avg FLOAT,
contention_time_var FLOAT,
cpu_nanos_avg FLOAT,
cpu_nanos_var FLOAT,
cpu_sql_nanos_avg FLOAT,
cpu_sql_nanos_var FLOAT,
implicit_txn BOOL NOT NULL,
full_scan BOOL NOT NULL,
sample_plan JSONB,
Expand Down Expand Up @@ -1474,8 +1474,8 @@ CREATE TABLE crdb_internal.node_statement_statistics (
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.MaxDiskUsage), // max_disk_usage_var
execStatAvg(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.ContentionTime), // contention_time_avg
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.ContentionTime), // contention_time_var
execStatAvg(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUNanos), // cpu_nanos_avg
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUNanos), // cpu_nanos_var
execStatAvg(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUSQLNanos), // cpu_sql_nanos_avg
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUSQLNanos), // cpu_sql_nanos_var
tree.MakeDBool(tree.DBool(stats.Key.ImplicitTxn)), // implicit_txn
tree.MakeDBool(tree.DBool(stats.Key.FullScan)), // full_scan
tree.NewDJSON(samplePlan), // sample_plan
Expand Down Expand Up @@ -1533,8 +1533,8 @@ CREATE TABLE crdb_internal.node_transaction_statistics (
max_disk_usage_var FLOAT,
contention_time_avg FLOAT,
contention_time_var FLOAT,
cpu_nanos_avg FLOAT,
cpu_nanos_var FLOAT
cpu_sql_nanos_avg FLOAT,
cpu_sql_nanos_var FLOAT
)
`,
populate: func(ctx context.Context, p *planner, _ catalog.DatabaseDescriptor, addRow func(...tree.Datum) error) error {
Expand Down Expand Up @@ -1589,8 +1589,8 @@ CREATE TABLE crdb_internal.node_transaction_statistics (
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.MaxDiskUsage), // max_disk_usage_var
execStatAvg(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.ContentionTime), // contention_time_avg
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.ContentionTime), // contention_time_var
execStatAvg(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUNanos), // cpu_nanos_avg
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUNanos), // cpu_nanos_var
execStatAvg(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUSQLNanos), // cpu_sql_nanos_avg
execStatVar(stats.Stats.ExecStats.Count, stats.Stats.ExecStats.CPUSQLNanos), // cpu_sql_nanos_var
)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/delegate/show_full_table_scans.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (d *delegator) delegateShowFullTableScans() (tree.Statement, error) {
sqltelemetry.IncrementShowCounter(sqltelemetry.FullTableScans)
const query = `
SELECT
key AS query, count, rows_read_avg, bytes_read_avg, service_lat_avg, contention_time_avg, max_mem_usage_avg, network_bytes_avg, cpu_nanos_avg, max_retries
key AS query, count, rows_read_avg, bytes_read_avg, service_lat_avg, contention_time_avg, max_mem_usage_avg, network_bytes_avg, cpu_sql_nanos_avg, max_retries
FROM crdb_internal.node_statement_statistics WHERE full_scan = TRUE ORDER BY count DESC`
return parse(query)
}
4 changes: 2 additions & 2 deletions pkg/sql/logictest/testdata/logic_test/crdb_internal
Original file line number Diff line number Diff line change
Expand Up @@ -328,12 +328,12 @@ node_id table_id name parent_id expiration deleted
query ITTTTTIIITRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRBBTTTTT colnames
SELECT * FROM crdb_internal.node_statement_statistics WHERE node_id < 0
----
node_id application_name flags statement_id key anonymized count first_attempt_count max_retries last_error rows_avg rows_var idle_lat_avg idle_lat_var parse_lat_avg parse_lat_var plan_lat_avg plan_lat_var run_lat_avg run_lat_var service_lat_avg service_lat_var overhead_lat_avg overhead_lat_var bytes_read_avg bytes_read_var rows_read_avg rows_read_var rows_written_avg rows_written_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_nanos_avg cpu_nanos_var implicit_txn full_scan sample_plan database_name exec_node_ids txn_fingerprint_id index_recommendations
node_id application_name flags statement_id key anonymized count first_attempt_count max_retries last_error rows_avg rows_var idle_lat_avg idle_lat_var parse_lat_avg parse_lat_var plan_lat_avg plan_lat_var run_lat_avg run_lat_var service_lat_avg service_lat_var overhead_lat_avg overhead_lat_var bytes_read_avg bytes_read_var rows_read_avg rows_read_var rows_written_avg rows_written_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_sql_nanos_avg cpu_sql_nanos_var implicit_txn full_scan sample_plan database_name exec_node_ids txn_fingerprint_id index_recommendations

query ITTTIIRRRRRRRRRRRRRRRRRRRRRR colnames
SELECT * FROM crdb_internal.node_transaction_statistics WHERE node_id < 0
----
node_id application_name key statement_ids count max_retries service_lat_avg service_lat_var retry_lat_avg retry_lat_var commit_lat_avg commit_lat_var idle_lat_avg idle_lat_var rows_read_avg rows_read_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_nanos_avg cpu_nanos_var
node_id application_name key statement_ids count max_retries service_lat_avg service_lat_var retry_lat_avg retry_lat_var commit_lat_avg commit_lat_var idle_lat_avg idle_lat_var rows_read_avg rows_read_var network_bytes_avg network_bytes_var network_msgs_avg network_msgs_var max_mem_usage_avg max_mem_usage_var max_disk_usage_avg max_disk_usage_var contention_time_avg contention_time_var cpu_sql_nanos_avg cpu_sql_nanos_var

query IITTTTTTT colnames
SELECT * FROM crdb_internal.session_trace WHERE span_idx < 0
Expand Down
Loading

0 comments on commit fd5d88b

Please sign in to comment.