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

planner: explain a physicalPlan with IndexMerge in "dot" format #12248

Merged
merged 2 commits into from Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions cmd/explaintest/r/explain_indexmerge.result
Expand Up @@ -48,3 +48,36 @@ IndexMerge_17 0.00 root
├─IndexScan_14 9.00 cop table:t, index:d, range:[-inf,10), keep order:false
└─Selection_16 0.00 cop lt(Column#6, 10), or(lt(Column#2, 10000), lt(Column#3, 10000))
└─TableScan_15 18.00 cop table:t, keep order:false
explain format="dot" select * from t where (a < 50 or b < 50) and f > 100;
dot contents

digraph IndexMerge_12 {
subgraph cluster12{
node [style=filled, color=lightgrey]
color=black
label = "root"
"IndexMerge_12"
}
subgraph cluster8{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"TableScan_8"
}
subgraph cluster9{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"IndexScan_9"
}
subgraph cluster11{
node [style=filled, color=lightgrey]
color=black
label = "cop"
"Selection_11" -> "TableScan_10"
}
"IndexMerge_12" -> "TableScan_8"
"IndexMerge_12" -> "IndexScan_9"
"IndexMerge_12" -> "Selection_11"
}

1 change: 1 addition & 0 deletions cmd/explaintest/t/explain_indexmerge.test
Expand Up @@ -12,3 +12,4 @@ explain select * from t where b < 50 or c < 50;
explain select * from t where b < 50 or c < 5000000;
explain select * from t where a < 50 or b < 50 or c < 50;
explain select * from t where (b < 10000 or c < 10000) and (a < 10 or d < 10) and f < 10;
explain format="dot" select * from t where (a < 50 or b < 50) and f > 100;
9 changes: 9 additions & 0 deletions planner/core/common_plans.go
Expand Up @@ -808,6 +808,15 @@ func (e *Explain) prepareTaskDot(p PhysicalPlan, taskTp string, buffer *bytes.Bu
pipelines = append(pipelines, fmt.Sprintf("\"%s\" -> \"%s\"\n", copPlan.ExplainID(), copPlan.indexPlan.ExplainID()))
copTasks = append(copTasks, copPlan.tablePlan)
copTasks = append(copTasks, copPlan.indexPlan)
case *PhysicalIndexMergeReader:
for i := 0; i < len(copPlan.partialPlans); i++ {
pipelines = append(pipelines, fmt.Sprintf("\"%s\" -> \"%s\"\n", copPlan.ExplainID(), copPlan.partialPlans[i].ExplainID()))
copTasks = append(copTasks, copPlan.partialPlans[i])
}
if copPlan.tablePlan != nil {
pipelines = append(pipelines, fmt.Sprintf("\"%s\" -> \"%s\"\n", copPlan.ExplainID(), copPlan.tablePlan.ExplainID()))
copTasks = append(copTasks, copPlan.tablePlan)
}
}
for _, child := range curPlan.Children() {
fmt.Fprintf(buffer, "\"%s\" -> \"%s\"\n", curPlan.ExplainID(), child.ExplainID())
Expand Down