Skip to content

Commit

Permalink
sql/tests: add ANALYZE to sysbench microbenchmark
Browse files Browse the repository at this point in the history
Collecting table statistics manually during the benchmark setup makes
the performance more representative of a real-world workload without the
variance in results that automatic stats collection would introduce.

Release note: None
  • Loading branch information
mgartner committed Dec 9, 2024
1 parent b0667c1 commit 5e7a5b1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/sql/tests/sysbench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const (
pad CHAR(60) NOT NULL DEFAULT ''
)`
sysbenchCreateIndex = `CREATE INDEX k_%[1]d ON sbtest%[1]d(k)` // https://github.com/akopytov/sysbench/blob/de18a036cc65196b1a4966d305f33db3d8fa6f8e/src/lua/oltp_common.lua#L245
sysbenchAnalyze = `ANALYZE sbtest%[1]d`

sysbenchStmtBegin = `BEGIN`
sysbenchStmtCommit = `COMMIT`
Expand Down Expand Up @@ -272,6 +273,9 @@ func (s *sysbenchSQL) prepSchema(rng *rand.Rand) {

// Create the secondary index on the table.
try(s.conn.Exec(s.ctx, fmt.Sprintf(sysbenchCreateIndex, i)))

// Collect table statistics.
try(s.conn.Exec(s.ctx, fmt.Sprintf(sysbenchAnalyze, i)))
}
}

Expand Down

0 comments on commit 5e7a5b1

Please sign in to comment.