Skip to content

Commit

Permalink
sql: add cpu nanos to insights tables
Browse files Browse the repository at this point in the history
Part Of #87213

Add `cpu_nanos` to
`crdb_internal.{cluster,nodes}_execution_insights` and
`crdb_internal.{cluster,nodes}_txn_execution_insights`.

Release note: None
  • Loading branch information
maryliag committed Jan 30, 2023
1 parent 3e65660 commit 440df83
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 18 deletions.
8 changes: 4 additions & 4 deletions pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ SELECT * FROM crdb_internal.node_inflight_trace_spans WHERE span_id < 0
----
trace_id parent_span_id span_id goroutine_id finished start_time duration operation

query TTTBTTTTTIITITTTTT colnames
query TTTBTTTTTIITITTTTTI colnames
SELECT * FROM crdb_internal.cluster_txn_execution_insights WHERE query = ''
----
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids cpu_sql_nanos

query TTTBTTTTTIITITTTTT colnames
query TTTBTTTTTIITITTTTTI colnames
SELECT * FROM crdb_internal.node_txn_execution_insights WHERE query = ''
----
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids cpu_sql_nanos

query ITTI
SELECT range_id, start_pretty, end_pretty, lease_holder FROM crdb_internal.ranges
Expand Down
8 changes: 6 additions & 2 deletions pkg/sql/crdb_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -6953,7 +6953,8 @@ CREATE TABLE crdb_internal.%s (
contention INTERVAL,
problems STRING[] NOT NULL,
causes STRING[] NOT NULL,
stmt_execution_ids STRING[] NOT NULL
stmt_execution_ids STRING[] NOT NULL,
cpu_sql_nanos INT8
)`

var crdbInternalClusterTxnExecutionInsightsTable = virtualSchemaTable{
Expand Down Expand Up @@ -7081,6 +7082,7 @@ func populateTxnExecutionInsights(
problems,
causes,
stmtIDs,
tree.NewDInt(tree.DInt(insight.Transaction.CPUSQLNanos)),
))

if err != nil {
Expand Down Expand Up @@ -7119,7 +7121,8 @@ CREATE TABLE crdb_internal.%s (
contention INTERVAL,
contention_events JSONB,
index_recommendations STRING[] NOT NULL,
implicit_txn BOOL NOT NULL
implicit_txn BOOL NOT NULL,
cpu_sql_nanos INT8
)`

var crdbInternalClusterExecutionInsightsTable = virtualSchemaTable{
Expand Down Expand Up @@ -7249,6 +7252,7 @@ func populateStmtInsights(
contentionEvents,
indexRecommendations,
tree.MakeDBool(tree.DBool(insight.Transaction.ImplicitTxn)),
tree.NewDInt(tree.DInt(s.CPUSQLNanos)),
))
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/logictest/testdata/logic_test/crdb_internal
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,16 @@ SELECT * FROM crdb_internal.ranges_no_leases WHERE range_id < 0
----
range_id start_key start_pretty end_key end_pretty replicas replica_localities voting_replicas non_voting_replicas learner_replicas split_enforced_until

query TTTBTTTTTIITITTTTT colnames
query TTTBTTTTTIITITTTTTI colnames
SELECT * FROM crdb_internal.cluster_txn_execution_insights WHERE query = ''
----
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids cpu_sql_nanos


query TTTBTTTTTIITITTTTT colnames
query TTTBTTTTTIITITTTTTI colnames
SELECT * FROM crdb_internal.node_txn_execution_insights WHERE query = ''
----
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids
txn_id txn_fingerprint_id query implicit_txn session_id start_time end_time user_name app_name rows_read rows_written priority retries last_retry_reason contention problems causes stmt_execution_ids cpu_sql_nanos


statement ok
Expand Down
Loading

0 comments on commit 440df83

Please sign in to comment.