Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
zanmato1984 committed Aug 14, 2024
1 parent 3c4129c commit b7a7001
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
30 changes: 23 additions & 7 deletions cmd/go-tpc/tpch.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,24 @@ import (

var tpchConfig tpch.Config

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

func executeTpch(action string) {
if tpchConfig.EnableQueryTuning {
}

openDB()
defer closeDB()

Expand All @@ -34,7 +51,6 @@ func executeTpch(action string) {
tpchConfig.DBName = dbName
tpchConfig.PrepareThreads = threads
tpchConfig.QueryNames = strings.Split(tpchConfig.RawQueries, ",")
tpchConfig.QueryTuningConfig.Vars = strings.Split(tpchConfig.QueryTuningConfig.VarsRaw, ";")
w := tpch.NewWorkloader(globalDB, &tpchConfig)
timeoutCtx, cancel := context.WithTimeout(globalCtx, totalTime)
defer cancel()
Expand Down Expand Up @@ -131,14 +147,14 @@ func registerTpch(root *cobra.Command) {
"",
"Name of plan Replayer file dumps")

cmdRun.PersistentFlags().BoolVar(&tpchConfig.QueryTuningConfig.Enable,
cmdRun.PersistentFlags().BoolVar(&tpchConfig.EnableQueryTuning,
"enable-query-tuning",
true,
"Enable query tuning by setting specified session variables")
cmdRun.PersistentFlags().StringVar(&tpchConfig.QueryTuningConfig.VarsRaw,
"query-tuning-vars",
"tidb_default_string_match_selectivity=0.1;tidb_opt_join_reorder_threshold=60;tidb_prefer_broadcast_join_by_exchange_data_size=ON",
"Specify a sequence of session variables to set before executing each query, in the form of 'name=value', separated by semicolon. Defaulted to some variables known effective for tpch queries.")
"Tune queries by setting some session variables known effective for tpch")
// cmdRun.PersistentFlags().StringVar(&tpchConfig.QueryTuningConfig.VarsRaw,
// "query-tuning-vars",
// "tidb_default_string_match_selectivity=0.1;tidb_opt_join_reorder_threshold=60;tidb_prefer_broadcast_join_by_exchange_data_size=ON",
// "Specify a sequence of session variables to set before executing each query, in the form of 'name=value', separated by semicolon. Defaulted to some variables known effective for tpch queries.")

var cmdCleanup = &cobra.Command{
Use: "cleanup",
Expand Down
8 changes: 1 addition & 7 deletions tpch/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ type analyzeConfig struct {
IndexSerialScanConcurrency int
}

type queryTuningConfig struct {
Enable bool
VarsRaw string
Vars []string
}

// Config is the configuration for tpch workload
type Config struct {
Driver string
Expand All @@ -51,7 +45,7 @@ type Config struct {
PlanReplayerConfig replayer.PlanReplayerConfig
EnablePlanReplayer bool

QueryTuningConfig queryTuningConfig
EnableQueryTuning bool

// for prepare command only
OutputType string
Expand Down

0 comments on commit b7a7001

Please sign in to comment.