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

tpch: add query tuning configs for tpch #179

Merged
merged 7 commits into from
Aug 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions cmd/go-tpc/tpch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,31 @@ import (

var tpchConfig tpch.Config

var queryTuningVars = []struct {
name string
value string
}{
// For optimal join order, esp. for q9.
{"tidb_default_string_match_selectivity", "0.1"},
// For optimal join order for all queries.
{"tidb_opt_join_reorder_threshold", "60"},
// For optimal join type between broadcast and hash partition join.
{"tidb_prefer_broadcast_join_by_exchange_data_size", "ON"},
}

func appendQueryTuningVarsToConnParams() {
for _, v := range queryTuningVars {
if !strings.Contains(connParams, v.name) {
connParams = fmt.Sprintf("%s&%s=%s", connParams, v.name, v.value)
}
}
}

func executeTpch(action string) {
if action == "run" && driver == "mysql" && tpchConfig.EnableQueryTuning {
Copy link
Contributor Author

@zanmato1984 zanmato1984 Aug 19, 2024

Choose a reason for hiding this comment

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

This has to come prior to openDB() call because it leverages connection parameters which only take effect when connecting to the database.

appendQueryTuningVarsToConnParams()
}

openDB()
defer closeDB()

Expand Down Expand Up @@ -130,6 +154,11 @@ func registerTpch(root *cobra.Command) {
"",
"Name of plan Replayer file dumps")

cmdRun.PersistentFlags().BoolVar(&tpchConfig.EnableQueryTuning,
"enable-query-tuning",
true,
"Tune queries by setting some session variables known effective for tpch")

var cmdCleanup = &cobra.Command{
Use: "cleanup",
Short: "Cleanup data for the workload",
Expand Down
2 changes: 2 additions & 0 deletions tpch/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ type Config struct {
PlanReplayerConfig replayer.PlanReplayerConfig
EnablePlanReplayer bool

EnableQueryTuning bool

// for prepare command only
OutputType string
OutputDir string
Expand Down
Loading