Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roachpb/sql/ui: add mean rows written to Statement Details page #70377

Merged
merged 1 commit into from
Sep 22, 2021

Conversation

lindseyjin
Copy link
Contributor

@lindseyjin lindseyjin commented Sep 17, 2021

Resolves #67084

Previously, the Statement Details page did not show the mean rows
written to. We received feedback to surface rows affected.

To address this, we are adding "mean rows written" to non-SELECT
statements. This has been added as a row on the Statement Details
Overview page and on the Execution Stats "Other Execution Stats" table.
A future PR will also add this new metric to the column selector on
the Statements Overview page.

image

image

Release note (ui change): add mean rows written to statement details page

@lindseyjin lindseyjin requested a review from a team as a code owner September 17, 2021 20:11
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@lindseyjin
Copy link
Contributor Author

hi! sorry y'all, I somehow closed my last PR when I was trying to rebase on upstream. I couldn't figure out how to recover that, so I've created a new one (although let me know if you have any tips if I run into this issue in the future!)

@lindseyjin lindseyjin requested review from a team and removed request for a team September 17, 2021 20:14
@lindseyjin lindseyjin force-pushed the add-mean-rows-written branch 2 times, most recently from 61c6631 to c769f07 Compare September 17, 2021 21:11
Copy link
Contributor

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 14 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @lindseyjin)


pkg/roachpb/app_stats.proto, line 90 at r1 (raw file):

  optional NumericStat rows_read = 16 [(gogoproto.nullable) = false];

  // RowsWritten collects the number of rows read from disk.

s/rows read from/rows written to/


pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx, line 506 at r1 (raw file):

      );
    const summary = summarize(statement);
    const notSelectStatement = summary.statement !== "select";

Reading the function of summarize(), I think this would also include statements like SET CLUSTER SETTINGS ... even though those statements does not always change stored data on disk.

Also, I feel this summarize() function doesn't capture the full picture. We also have UPSERT statements that does conditional update/insert operations.

Additionally, user can do PREPARE insert_stmt AS INSERT INTO table VALUES ($1) and then EXECUTE insert_stmt(...), the subsequent EXECUTE would also have mean rows written stats.

cc @maryliag any thoughts on handling these special cases ?

Copy link
Contributor Author

@lindseyjin lindseyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @lindseyjin and @maryliag)


pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx, line 506 at r1 (raw file):

Previously, Azhng (Archer Zhang) wrote…

Reading the function of summarize(), I think this would also include statements like SET CLUSTER SETTINGS ... even though those statements does not always change stored data on disk.

Also, I feel this summarize() function doesn't capture the full picture. We also have UPSERT statements that does conditional update/insert operations.

Additionally, user can do PREPARE insert_stmt AS INSERT INTO table VALUES ($1) and then EXECUTE insert_stmt(...), the subsequent EXECUTE would also have mean rows written stats.

cc @maryliag any thoughts on handling these special cases ?

Hmm, currently the ticket only mentions hiding this metric for SELECT statements. Is the problem that we don't want to show "mean rows written" for any statements that aren't able to modify rows?

Copy link
Contributor Author

@lindseyjin lindseyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)


pkg/roachpb/app_stats.proto, line 90 at r1 (raw file):

Previously, Azhng (Archer Zhang) wrote…

s/rows read from/rows written to/

Done.

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng)


pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx, line 506 at r1 (raw file):

Previously, lindseyjin (Lindsey Jin) wrote…

Hmm, currently the ticket only mentions hiding this metric for SELECT statements. Is the problem that we don't want to show "mean rows written" for any statements that aren't able to modify rows?

I had left a previous comment on the other PR, for this here you need to checks: only show if statement type is DML, and if it is DML hide if is select type.
So I would change the notSelectStatement const to showRowsWritten and its value would be something like this (not sure the right parameter name for SQL Type)
const showRowsWritten = statement.sqltype === 'DML' and summary.statement !== 'statement'

and then below you can show {showRowsWritten && (...

Copy link
Contributor Author

@lindseyjin lindseyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng)


pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx, line 506 at r1 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

I had left a previous comment on the other PR, for this here you need to checks: only show if statement type is DML, and if it is DML hide if is select type.
So I would change the notSelectStatement const to showRowsWritten and its value would be something like this (not sure the right parameter name for SQL Type)
const showRowsWritten = statement.sqltype === 'DML' and summary.statement !== 'statement'

and then below you can show {showRowsWritten && (...

Done!

Couldn't find if there was an existing enum for sql types, but let me know if one exists!

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 10 of 14 files at r1, 1 of 1 files at r3, 2 of 2 files at r4, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng, @lindseyjin, and @maryliag)


pkg/ui/workspaces/cluster-ui/src/statementDetails/statementDetails.tsx, line 581 at r4 (raw file):

                        <Text>
                          {formatNumberForDisplay(
                            stats.rows_written.mean,

nit: to account for cluster with version where this parameter might not exist, change this to stats.rows_written?.mean


pkg/ui/workspaces/cluster-ui/src/statementsPage/statementsPage.fixture.ts, line 92 at r4 (raw file):

  },
  rows_written: {
    mean: 10,

nit: use a different value from rows read, because during tests we want different values to make sure we're not using a value from a different parameter for example


pkg/ui/workspaces/cluster-ui/src/util/appStats/appStats.fixture.ts, line 208 at r4 (raw file):

        squared_diffs: 3.8399999999999994,
      },
      rows_written: {

nit: same as the other comment, change the values of rows written to some other random value different from rows read


pkg/ui/workspaces/db-console/src/util/appStats.ts, line 85 at r4 (raw file):

    bytes_read: addNumericStats(a.bytes_read, b.bytes_read, countA, countB),
    rows_read: addNumericStats(a.rows_read, b.rows_read, countA, countB),
    rows_written: addNumericStats(a.rows_read, b.rows_read, countA, countB),

this is suppose to be rows_written, you forgot to change the values inside the function

@lindseyjin lindseyjin force-pushed the add-mean-rows-written branch 3 times, most recently from fa237d1 to ac7c3ad Compare September 21, 2021 15:54
Copy link
Contributor Author

@lindseyjin lindseyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Azhng and @maryliag)


pkg/ui/workspaces/db-console/src/util/appStats.ts, line 85 at r4 (raw file):

Previously, maryliag (Marylia Gutierrez) wrote…

this is suppose to be rows_written, you forgot to change the values inside the function

Done.

@lindseyjin lindseyjin force-pushed the add-mean-rows-written branch 3 times, most recently from 0de6ade to 56f14ab Compare September 21, 2021 20:18
Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!
:lgtm:

Reviewed 1 of 14 files at r1, 2 of 4 files at r5, 1 of 1 files at r6, 1 of 1 files at r7, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @Azhng)

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized that this metric should also be added to the Execution Stats Tab of the Statement Details. Can you add it there? Just below the read row on the "Other Execution Statistics". table

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @Azhng)

Copy link
Contributor Author

@lindseyjin lindseyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it! do I just need to add this into the "Other Execution Stats" table, or also the "Stats By Node" table?\

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng and @maryliag)

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That stats by node is based on the same statement table from the main page, so once you add there on your following task, it will get added on this table too. So don't worry about it on this PR, but on your next one make sure you test on this page

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng and @maryliag)

Copy link
Contributor Author

@lindseyjin lindseyjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sounds good!
Also, done!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng and @maryliag)

Copy link
Contributor

@Azhng Azhng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @Azhng and @maryliag)

Copy link
Contributor

@maryliag maryliag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 1 of 1 files at r8.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @maryliag)

Resolves cockroachdb#67084

Previously, the Statement Details page did not show the mean rows
written to. We received feedback to surface rows affected.

To address this, we are adding "mean rows written" to non-SELECT
statements. This has been added as a row on the Statement Details
Overview page and on the Execution Stats "Other Execution Stats" table.
A future PR will also add this new metric to the column selector on
the Statements Overview page.

Release note (ui change): add mean rows written to statement details page
@lindseyjin
Copy link
Contributor Author

^^ Pushing to resolve merge conflicts

@lindseyjin
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 22, 2021

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Surface the number affected rows in the DB console for statement statistics
4 participants