Skip to content

auto-analyze is slow due to hardcoded concurrency 1 #37183

@chrysan

Description

@chrysan

Enhancement

auto-analyze concurrency is now hardcoded to be 1 which causes auto-analyze runs too slowly and may fail due to exceeding gc-life-time at versions before v6.2

tidb/executor/adapter.go

Lines 120 to 135 in 3507a72

if _, ok := a.plan.(*plan.Analyze); ok && ctx.GetSessionVars().InRestrictedSQL {
oriStats := ctx.GetSessionVars().Systems[variable.TiDBBuildStatsConcurrency]
oriScan := ctx.GetSessionVars().DistSQLScanConcurrency
oriIndex := ctx.GetSessionVars().IndexSerialScanConcurrency
oriIso := ctx.GetSessionVars().Systems[variable.TxnIsolation]
ctx.GetSessionVars().Systems[variable.TiDBBuildStatsConcurrency] = "1"
ctx.GetSessionVars().DistSQLScanConcurrency = 1
ctx.GetSessionVars().IndexSerialScanConcurrency = 1
ctx.GetSessionVars().Systems[variable.TxnIsolation] = ast.ReadCommitted
defer func() {
ctx.GetSessionVars().Systems[variable.TiDBBuildStatsConcurrency] = oriStats
ctx.GetSessionVars().DistSQLScanConcurrency = oriScan
ctx.GetSessionVars().IndexSerialScanConcurrency = oriIndex
ctx.GetSessionVars().Systems[variable.TxnIsolation] = oriIso
}()
}

Metadata

Metadata

Assignees

Labels

type/enhancementThe issue or PR belongs to an enhancement.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions