Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
69597: roachpb,sql.ui: remove Opt field from StatementStatisticsKey r=matthewtodd a=Azhng

Resolves cockroachdb#68077

Release note: None

70364: docs: update readme for cluster-ui r=xinhaoz a=Azhng

Previsouly, README in cluster-ui points to an incorrect directory
to run yarn command.
This commit update the directory mentioned in the README.

Release note: None

Co-authored-by: Azhng <archer.xn@gmail.com>
  • Loading branch information
2 people authored and lindseyjin committed Sep 17, 2021
3 parents c6f08db + 08b663b + 552c65a commit e6ec612
Show file tree
Hide file tree
Showing 24 changed files with 246 additions and 208 deletions.
4 changes: 3 additions & 1 deletion pkg/roachpb/app_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func (s *StatementStatistics) Add(other *StatementStatistics) {
s.OverheadLat.Add(other.OverheadLat, s.Count, other.Count)
s.BytesRead.Add(other.BytesRead, s.Count, other.Count)
s.RowsRead.Add(other.RowsRead, s.Count, other.Count)
s.RowsWritten.Add(other.RowsWritten, s.Count, other.Count)
s.Nodes = util.CombineUniqueInt64(s.Nodes, other.Nodes)

s.ExecStats.Add(other.ExecStats)
Expand Down Expand Up @@ -181,7 +182,8 @@ func (s *StatementStatistics) AlmostEqual(other *StatementStatistics, eps float6
s.OverheadLat.AlmostEqual(other.OverheadLat, eps) &&
s.SensitiveInfo.Equal(other.SensitiveInfo) &&
s.BytesRead.AlmostEqual(other.BytesRead, eps) &&
s.RowsRead.AlmostEqual(other.RowsRead, eps)
s.RowsRead.AlmostEqual(other.RowsRead, eps) &&
s.RowsWritten.AlmostEqual(other.RowsWritten, eps)
// s.ExecStats are deliberately ignored since they are subject to sampling
// probability and are not fully deterministic (e.g. the number of network
// messages depends on the range cache state).
Expand Down
307 changes: 164 additions & 143 deletions pkg/roachpb/app_stats.pb.go

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion pkg/roachpb/app_stats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ message StatementStatistics {
// RowsRead collects the number of rows read from disk.
optional NumericStat rows_read = 16 [(gogoproto.nullable) = false];

// RowsWritten collects the number of rows read from disk.
optional NumericStat rows_written = 25 [(gogoproto.nullable) = false];

// ExecStats are the execution statistics for this statement. These statistics
// are sampled.
optional ExecStats exec_stats = 21 [(gogoproto.nullable) = false];
Expand Down Expand Up @@ -174,12 +177,13 @@ message StatementStatisticsKey {
optional string app = 2 [(gogoproto.nullable) = false];
optional bool distSQL = 3 [(gogoproto.nullable) = false];
optional bool failed = 4 [(gogoproto.nullable) = false];
optional bool opt = 5 [(gogoproto.nullable) = false];
optional bool implicit_txn = 6 [(gogoproto.nullable) = false];
optional bool vec = 7 [(gogoproto.nullable) = false];
optional bool full_scan = 8 [(gogoproto.nullable) = false];
optional string database = 9 [(gogoproto.nullable) = false];
optional uint64 plan_hash = 10 [(gogoproto.nullable) = false];

reserved 5;
}

// CollectedStatementStatistics wraps collected timings and metadata for some
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/executor_statement_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ func (ex *connExecutor) recordStatementSummary(
OverheadLatency: execOverhead,
BytesRead: stats.bytesRead,
RowsRead: stats.rowsRead,
RowsWritten: stats.rowsWritten,
Nodes: getNodesFromPlanner(planner),
StatementType: stmt.AST.StatementType(),
Plan: planner.instrumentation.PlanForStats(ctx),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ func ExplainTreePlanNodeToJSON(node *roachpb.ExplainTreePlanNode) json.JSON {
// "db": { "type": "string" },
// "distsql": { "type": "boolean" },
// "failed": { "type": "boolean" },
// "opt": { "type": "boolean" },
// "implicitTxn": { "type": "boolean" },
// "vec": { "type": "boolean" },
// "fullScan": { "type": "boolean" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func TestSQLStatsJsonEncoding(t *testing.T) {
"db": "{{.String}}",
"distsql": {{.Bool}},
"failed": {{.Bool}},
"opt": {{.Bool}},
"implicitTxn": {{.Bool}},
"vec": {{.Bool}},
"fullScan": {{.Bool}}
Expand Down Expand Up @@ -92,6 +91,10 @@ func TestSQLStatsJsonEncoding(t *testing.T) {
"mean": {{.Float}},
"sqDiff": {{.Float}}
},
"rowsWritten": {
"mean": {{.Float}},
"sqDiff": {{.Float}}
},
"nodes": [{{joinInts .IntArray}}]
},
"execution_statistics": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func (s *stmtStatsMetadata) jsonFields() jsonFields {
{"db", (*jsonString)(&s.Key.Database)},
{"distsql", (*jsonBool)(&s.Key.DistSQL)},
{"failed", (*jsonBool)(&s.Key.Failed)},
{"opt", (*jsonBool)(&s.Key.Opt)},
{"implicitTxn", (*jsonBool)(&s.Key.ImplicitTxn)},
{"vec", (*jsonBool)(&s.Key.Vec)},
{"fullScan", (*jsonBool)(&s.Key.FullScan)},
Expand Down Expand Up @@ -234,6 +233,7 @@ func (s *innerStmtStats) jsonFields() jsonFields {
{"ovhLat", (*numericStats)(&s.OverheadLat)},
{"bytesRead", (*numericStats)(&s.BytesRead)},
{"rowsRead", (*numericStats)(&s.RowsRead)},
{"rowsWritten", (*numericStats)(&s.RowsWritten)},
{"nodes", (*int64Array)(&s.Nodes)},
}
}
Expand Down
3 changes: 0 additions & 3 deletions pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ func GetRandomizedCollectedStatementStatisticsForTest(
data := genRandomData()
fillObject(t, reflect.ValueOf(&result), &data)

// TODO(azhng): Gone after https://github.com/cockroachdb/cockroach/issues/68077.
result.Key.Opt = true

return result
}

Expand Down
1 change: 0 additions & 1 deletion pkg/sql/sqlstats/ssmemstorage/ss_mem_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func (s *StmtStatsIterator) Next() bool {
Key: roachpb.StatementStatisticsKey{
Query: stmtKey.anonymizedStmt,
DistSQL: distSQLUsed,
Opt: true,
Vec: vectorized,
ImplicitTxn: stmtKey.implicitTxn,
FullScan: fullScan,
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/sqlstats/ssmemstorage/ss_mem_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (s *Container) RecordStatement(
stats.mu.data.OverheadLat.Record(stats.mu.data.Count, value.OverheadLatency)
stats.mu.data.BytesRead.Record(stats.mu.data.Count, float64(value.BytesRead))
stats.mu.data.RowsRead.Record(stats.mu.data.Count, float64(value.RowsRead))
stats.mu.data.RowsWritten.Record(stats.mu.data.Count, float64(value.RowsWritten))
stats.mu.data.LastExecTimestamp = timeutil.Now()
stats.mu.data.Nodes = util.CombineUniqueInt64(stats.mu.data.Nodes, value.Nodes)
// Note that some fields derived from tracing statements (such as
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/sqlstats/ssprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ type RecordedStmtStats struct {
OverheadLatency float64
BytesRead int64
RowsRead int64
RowsWritten int64
Nodes []int64
StatementType tree.StatementType
Plan *roachpb.ExplainTreePlanNode
Expand Down
2 changes: 1 addition & 1 deletion pkg/ui/workspaces/cluster-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ and install it from a local tarball. To view a local change to cluster-ui in Coc
# in the root of cockroachdb/cockroach
$ make pkg/ui/yarn.protobuf.installed -B
$ make pkg/ui/yarn.cluster-ui.installed -B
# in pkg/ui/cluster-ui
# in pkg/ui/workspaces/cluster-ui
$ yarn run build
$ yarn pack --prod
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ export const getStatementDetailsPropsFixture = (): StatementDetailsProps => ({
numerator: 36958,
denominator: 36958,
},
opt: {
numerator: 36958,
denominator: 36958,
},
implicit_txn: {
numerator: 36958,
denominator: 36958,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ export const selectStatement = createSelector(
database: getMatchParamByName(props.match, databaseAttr),
distSQL: fractionMatching(results, s => s.distSQL),
vec: fractionMatching(results, s => s.vec),
opt: fractionMatching(results, s => s.opt),
implicit_txn: fractionMatching(results, s => s.implicit_txn),
full_scan: fractionMatching(results, s => s.full_scan),
failed: fractionMatching(results, s => s.failed),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
formatNumberForDisplay,
calculateTotalWorkload,
unique,
summarize,
} from "src/util";
import { Loading } from "src/loading";
import { Button } from "src/button";
Expand Down Expand Up @@ -76,7 +77,6 @@ interface SingleStatementStatistics {
database: string;
distSQL: Fraction;
vec: Fraction;
opt: Fraction;
implicit_txn: Fraction;
failed: Fraction;
node_id: number[];
Expand Down Expand Up @@ -439,7 +439,6 @@ export class StatementDetails extends React.Component<
app,
distSQL,
vec,
opt,
failed,
implicit_txn,
database,
Expand Down Expand Up @@ -503,6 +502,9 @@ export class StatementDetails extends React.Component<
moment(stats.last_exec_timestamp.seconds.low * 1e3).format(
"MMM DD, YYYY HH:MM",
);
const summary = summarize(statement);
const notSelectStatement = summary.statement !== "select";

return (
<Tabs
defaultActiveKey="1"
Expand Down Expand Up @@ -568,6 +570,19 @@ export class StatementDetails extends React.Component<
{formatNumberForDisplay(stats.bytes_read.mean, Bytes)}
</Text>
</div>
{notSelectStatement && (
<div
className={summaryCardStylesCx("summary--card__item")}
>
<Text>Mean rows written</Text>
<Text>
{formatNumberForDisplay(
stats.rows_written.mean,
formatTwoPlaces,
)}
</Text>
</div>
)}
<div className={summaryCardStylesCx("summary--card__item")}>
<Text>Max memory usage</Text>
<Text>
Expand Down Expand Up @@ -642,10 +657,6 @@ export class StatementDetails extends React.Component<
<Text>Failed?</Text>
<Text>{renderBools(failed)}</Text>
</div>
<div className={summaryCardStylesCx("summary--card__item")}>
<Text>Used cost-based optimizer?</Text>
<Text>{renderBools(opt)}</Text>
</div>
<div className={summaryCardStylesCx("summary--card__item")}>
<Text>Distributed execution?</Text>
<Text>{renderBools(distSQL)}</Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const statementStats: Required<IStatementStatistics> = {
mean: 10,
squared_diffs: 1,
},
rows_written: {
mean: 10,
squared_diffs: 1,
},
exec_stats: execStats,
last_exec_timestamp: {
seconds: Long.fromInt(1599670292),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-update-session",
distSQL: false,
failed: false,
opt: true,
implicit_txn: false,
vec: false,
},
Expand Down Expand Up @@ -125,7 +124,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-fetch-single-session",
distSQL: false,
failed: false,
opt: true,
implicit_txn: false,
vec: false,
},
Expand Down Expand Up @@ -190,7 +188,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-read orphaned leases",
distSQL: false,
failed: false,
opt: true,
implicit_txn: true,
vec: false,
},
Expand Down Expand Up @@ -246,7 +243,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-expire-sessions",
distSQL: false,
failed: false,
opt: true,
implicit_txn: true,
vec: false,
},
Expand Down Expand Up @@ -343,7 +339,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-insert-session",
distSQL: false,
failed: false,
opt: true,
implicit_txn: false,
vec: false,
},
Expand Down Expand Up @@ -393,7 +388,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-show-version",
distSQL: false,
failed: false,
opt: true,
implicit_txn: true,
vec: false,
},
Expand Down Expand Up @@ -432,7 +426,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-read-setting",
distSQL: false,
failed: false,
opt: true,
implicit_txn: false,
vec: false,
},
Expand Down Expand Up @@ -482,7 +475,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-protectedts-GetMetadata",
distSQL: false,
failed: false,
opt: true,
implicit_txn: false,
vec: false,
},
Expand Down Expand Up @@ -570,7 +562,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-delete-sessions",
distSQL: false,
failed: false,
opt: true,
implicit_txn: true,
vec: false,
},
Expand Down Expand Up @@ -682,7 +673,6 @@ export const data: cockroach.server.serverpb.IStatementsResponse = {
app: "$ internal-log-event",
distSQL: false,
failed: false,
opt: true,
implicit_txn: false,
vec: false,
},
Expand Down
Loading

0 comments on commit e6ec612

Please sign in to comment.