From b7a70010d4ebe561f65344f626ec5424281c8d44 Mon Sep 17 00:00:00 2001 From: Ruoxi Sun Date: Wed, 14 Aug 2024 20:49:17 +0800 Subject: [PATCH] WIP --- cmd/go-tpc/tpch.go | 30 +++++++++++++++++++++++------- tpch/workload.go | 8 +------- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/cmd/go-tpc/tpch.go b/cmd/go-tpc/tpch.go index 256e2a4..8905a1c 100644 --- a/cmd/go-tpc/tpch.go +++ b/cmd/go-tpc/tpch.go @@ -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() @@ -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() @@ -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", diff --git a/tpch/workload.go b/tpch/workload.go index 48d7cb3..48d28b9 100644 --- a/tpch/workload.go +++ b/tpch/workload.go @@ -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 @@ -51,7 +45,7 @@ type Config struct { PlanReplayerConfig replayer.PlanReplayerConfig EnablePlanReplayer bool - QueryTuningConfig queryTuningConfig + EnableQueryTuning bool // for prepare command only OutputType string