Skip to content

Commit

Permalink
[Enhancement] Add candidate tuning guide to profile for easy troubles…
Browse files Browse the repository at this point in the history
…hooting (StarRocks#53618)

Signed-off-by: stephen <stephen5217@163.com>
  • Loading branch information
stephen-shelby authored Dec 6, 2024
1 parent 9e21051 commit 5173daf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.starrocks.common.Pair;
import com.starrocks.common.profile.Tracers;
import com.starrocks.qe.ConnectContext;
import com.starrocks.qe.SessionVariable;
import com.starrocks.qe.feedback.OperatorTuningGuides;
Expand Down Expand Up @@ -57,6 +58,14 @@ public OptExpression rewrite(OptExpression root, TaskContext taskContext) {
return root;
}

if (!tuningGuides.isEmpty()) {
if (!tuningGuides.isUseful()) {
Tracers.record("CandidateTuningGuides", "Tuning guides are useless");
} else {
Tracers.record("CandidateTuningGuides", tuningGuides.getTuneGuidesInfo(true));
}
}

// delete the useless tuning guides
if (!tuningGuides.isUseful()) {
PlanTuningAdvisor.getInstance().deleteTuningGuides(tuningGuides.getOriginalQueryId());
Expand Down
4 changes: 4 additions & 0 deletions test/sql/test_feedback/R/test_join_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ function: assert_trace_values_contains("select count(*) from (select * from c1_s
-- result:
None
-- !result
function: assert_trace_values_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "CandidateTuningGuides")
-- result:
None
-- !result
truncate plan advisor;
-- result:
[REGEX]Clear all plan advisor in FE.*
Expand Down
1 change: 1 addition & 0 deletions test/sql/test_feedback/T/test_join_feedback
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ function: assert_explain_not_contains("select count(*) from (select * from c1_sk
alter plan advisor add select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t;
function: assert_explain_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "RightChildEstimationErrorTuningGuide")
function: assert_trace_values_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "RightChildEstimationErrorTuningGuide")
function: assert_trace_values_contains("select count(*) from (select * from c1_skew t1 join (select * from c1_skew where c1 = 'f') t2 on t1.c2 = t2.c2) t", "CandidateTuningGuides")
truncate plan advisor;

0 comments on commit 5173daf

Please sign in to comment.