Skip to content

Commit

Permalink
order by length(plan_hint)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzf678 committed Dec 9, 2022
1 parent dddf480 commit 107d649
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion planner/core/planbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,8 @@ func fetchRecordFromClusterStmtSummary(sctx sessionctx.Context, planDigest strin
exec, _ := sctx.(sqlexec.SQLExecutor)
fields := "stmt_type, schema_name, digest_text, sample_user, prepared, query_sample_text, charset, collation, plan_hint"
sql := fmt.Sprintf("select %s from information_schema.cluster_statements_summary where plan_digest = '%s' union distinct ", fields, planDigest) +
fmt.Sprintf("select %s from information_schema.cluster_statements_summary_history where plan_digest = '%s' ", fields, planDigest)
fmt.Sprintf("select %s from information_schema.cluster_statements_summary_history where plan_digest = '%s' ", fields, planDigest) +
"order by length(plan_digest) desc"
rs, err := exec.ExecuteInternal(ctx, sql)
if rs == nil {
return nil, errors.New("can't find any plans for '" + planDigest + "'")
Expand Down

0 comments on commit 107d649

Please sign in to comment.