Skip to content

ui: new plan table on statement details#77632

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
maryliag:plan-hash-page
Mar 12, 2022
Merged

ui: new plan table on statement details#77632
craig[bot] merged 1 commit intocockroachdb:masterfrom
maryliag:plan-hash-page

Conversation

@maryliag
Copy link
Copy Markdown
Contributor

Previously, the Explain Plan tab on Statement Details was
showing only one plan. This commit introduces a table of plan
with their respective executions stats.
When a plan is clicked on the table, it shows the Plan and
its statistics.

Fixes #72129

Page on DB Console: video
Page on CC Console: video

Screen Shot 2022-03-10 at 2 42 25 PM

Screen Shot 2022-03-10 at 2 42 36 PM

Release justification: Category 4
Release note (ui change): Explain Plan tab on Statement Details
shows statistics for all the plans executed by the selected statement
on the selected period.

@maryliag maryliag requested a review from a team March 10, 2022 19:43
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@maryliag maryliag requested a review from Annebirzin March 10, 2022 21:06
Copy link
Copy Markdown
Contributor

@jocrl jocrl left a comment

Choose a reason for hiding this comment

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

Yay! 🙌

A few nits, but consider this an :lgtm: if you want to merge first and shelve any nits for later.

nit: Whether in this PR or next time, could you modify the statement details story to show multiple plans? So that the next dev doesn't need to figure out how to cause two different plans to make UI changes.

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


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

    } = this.props;
    const { currentTab } = this.state;
    const { statements_per_plan_hash } = this.props.statementDetails;

nit: I'm guessing this decision was made in the endpoint PR, but would it make more sense as s/statements_per_plan_hash/plan_hashes_per_statement?
The current name sounds like there are multiple statements for one plan hash. But as I'm understanding this, it's that there are multiple plan hashes for one statement fingerprint (or am I misunderstanding?).

Code quote:

statements_per_plan_hash

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

export function PlanDetails({ plans }: PlanDetailsProps): React.ReactElement {
  const [plan, setPlan] = useState(null);

nit: s/useState/useState<PlanHashStats|null> would be helpful typing

Code quote:

useState

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

  return [
    {
      name: "planID",

nit/side thought: I think this is interesting in that there have been a lot of PRs with tables and column identifiers and column names, and a question of how to restrict typing on those.

I'm assuming that these string names need to match type PlanDetailsTableColumnKeys. But there is no current type enforcement of that.

The suggestion I gave in Matthew and Xin Hao's PR was to use string enums; essentially that PlanDetailsTableColumnKey would be an enum type and one would do PlanDetailsTableColumnKey.planID here.

But this PR also presents a way of enforcing types on column configurations that is different from the strategy in Matthew and Xin Hao's recent PRs. So perhaps it would be helpful to step back and figure out we want to do.

Code quote:

ColumnDescriptor

Copy link
Copy Markdown
Contributor Author

@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.

Added two plans to stories

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


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

Previously, jocrl (Josephine) wrote…

nit: I'm guessing this decision was made in the endpoint PR, but would it make more sense as s/statements_per_plan_hash/plan_hashes_per_statement?
The current name sounds like there are multiple statements for one plan hash. But as I'm understanding this, it's that there are multiple plan hashes for one statement fingerprint (or am I misunderstanding?).

My idea here was more of a "statement statistics per plan hash", where this is a list with objects where the key is the hash and the value are the stats


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

Previously, jocrl (Josephine) wrote…

nit: s/useState/useState<PlanHashStats|null> would be helpful typing

Done


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

I'm assuming that these string names need to match type PlanDetailsTableColumnKeys
they don't need to match, they can be anything, we just use the same name to make it easier to identify

not sure how different it is, this strategy used here is the same used for the statements table columns (the one difference from that one is that the statements depends on a variable because the same table can exist on statement and transaction details page, so we need to know what to show on the tooltip, but that doesn't happen here)

Copy link
Copy Markdown
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.

Nice. :lgtm:

Reviewed 4 of 6 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @Annebirzin, @jocrl, and @maryliag)


pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx, line 30 at r2 (raw file):

  avg_exec_time: "Average Execution Time",
  exec_count: "Execution Count",
  avg_rows_read: "Average Rows Read",

nit: feels a bit that we are mixing snake case and camel case here. should we stick with camel case here?

Copy link
Copy Markdown
Contributor

@jocrl jocrl left a comment

Choose a reason for hiding this comment

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

Great, thanks! :lgtm:

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


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

Previously, maryliag (Marylia Gutierrez) wrote…

My idea here was more of a "statement statistics per plan hash", where this is a list with objects where the key is the hash and the value are the stats

Ooooo. I get it now 🙂.
For the future, maybe statements_stats_per_plan_hash? Or just plan_hash_stats, since it's a list and not a dictionary.


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

Previously, maryliag (Marylia Gutierrez) wrote…

I'm assuming that these string names need to match type PlanDetailsTableColumnKeys
they don't need to match, they can be anything, we just use the same name to make it easier to identify

not sure how different it is, this strategy used here is the same used for the statements table columns (the one difference from that one is that the statements depends on a variable because the same table can exist on statement and transaction details page, so we need to know what to show on the tooltip, but that doesn't happen here)

Right... The databases page does the equivalent of s/"planID"/PlanDetailsTableColumnKey.planID (see this comment, and the diff between r1 and r2).

It's a minor difference, but could be helpful with stricter typing since we have this pattern a lot. Unless you feel particularly inspired to do things now, I'm just thinking of this as food for thought.

Previously, the Explain Plan tab on Statement Details was
showing only one plan. This commit introduces a table of plan
with their respective executions stats.
When a plan is clicked on the table, it shows the Plan and
its statistics.

Fixes cockroachdb#72129

Release justification: Category 4
Release note (ui change): Explain Plan tab on Statement Details
shows statistics for all the plans executed by the selected statement
on the selected period.
Copy link
Copy Markdown
Contributor Author

@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 (and 2 stale) (waiting on @Annebirzin)


pkg/ui/workspaces/cluster-ui/src/statementDetails/planDetails/plansTable.tsx, line 30 at r2 (raw file):

Previously, Azhng (Archer Zhang) wrote…

nit: feels a bit that we are mixing snake case and camel case here. should we stick with camel case here?

Done

@maryliag
Copy link
Copy Markdown
Contributor Author

TFTR
bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 11, 2022

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 11, 2022

Build failed (retrying...):

Copy link
Copy Markdown

@Annebirzin Annebirzin left a comment

Choose a reason for hiding this comment

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

LGTM!

I did have one minor piece of feedback that's not a blocker. Across all detail pages, can we decrease the fixed height of all SQL text boxes to around 200px (not sure what the current height is), and then increase the fixed height of the Explain plan text box to around 450 px (since explain plans tend to be longer)?

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 12, 2022

Build succeeded:

@craig craig bot merged commit af747e7 into cockroachdb:master Mar 12, 2022
@maryliag maryliag deleted the plan-hash-page branch March 12, 2022 23:06
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.

Developers can view all distinct plans in an Explain plan tab including plan details

5 participants