Skip to content

Commit

Permalink
add flag for setting join concurrency. (pingcap#1619)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored Aug 22, 2016
1 parent b84b92f commit e487035
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plan/physical_plan_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
cpuFactor = 0.9
)

// JoinConcurrency means the number of goroutines that participate joining.
var JoinConcurrency = 5

func getRowCountByIndexRange(table *statistics.Table, indexRange *IndexRange, indexInfo *model.IndexInfo) (uint64, error) {
count := float64(table.Count)
for i := 0; i < len(indexRange.LowVal); i++ {
Expand Down Expand Up @@ -302,7 +305,7 @@ func (p *Join) handleLeftJoin(prop requiredProperty, innerJoin bool) (*physicalP
OtherConditions: p.OtherConditions,
SmallTable: 1,
// TODO: decide concurrency by data size.
Concurrency: 5,
Concurrency: JoinConcurrency,
}
join.SetSchema(p.schema)
if innerJoin {
Expand Down Expand Up @@ -344,7 +347,7 @@ func (p *Join) handleRightJoin(prop requiredProperty, innerJoin bool) (*physical
RightConditions: p.RightConditions,
OtherConditions: p.OtherConditions,
// TODO: decide concurrency by data size.
Concurrency: 5,
Concurrency: JoinConcurrency,
}
join.SetSchema(p.schema)
if innerJoin {
Expand Down
6 changes: 6 additions & 0 deletions tidb-server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/pingcap/tidb"
"github.com/pingcap/tidb/metric"
"github.com/pingcap/tidb/perfschema"
"github.com/pingcap/tidb/plan"
"github.com/pingcap/tidb/server"
"github.com/pingcap/tidb/store/localstore/boltdb"
"github.com/pingcap/tidb/store/tikv"
Expand All @@ -46,6 +47,7 @@ var (
enablePS = flag.Bool("perfschema", false, "If enable performance schema.")
reportStatus = flag.Bool("report-status", true, "If enable status report HTTP service.")
logFile = flag.String("log-file", "", "log file path")
joinCon = flag.Int("join-concurrency", 5, "the number of goroutines that participate joining.")
)

func main() {
Expand Down Expand Up @@ -79,6 +81,10 @@ func main() {
}
log.SetRotateByDay()
}

if joinCon != nil && *joinCon > 0 {
plan.JoinConcurrency = *joinCon
}
// Call this before setting log level to make sure that TiDB info could be printed.
printer.PrintTiDBInfo()
log.SetLevelByString(cfg.LogLevel)
Expand Down

0 comments on commit e487035

Please sign in to comment.