Skip to content

Commit

Permalink
workload: remove SQLDatabase from QueryLoad
Browse files Browse the repository at this point in the history
The field was unused.

Epic: None
Release note: None
  • Loading branch information
nvanbenschoten committed Apr 11, 2024
1 parent a489bd1 commit 87590cc
Show file tree
Hide file tree
Showing 23 changed files with 42 additions and 47 deletions.
4 changes: 2 additions & 2 deletions pkg/ccl/workloadccl/roachmartccl/roachmart.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (m *roachmart) Tables() []workload.Table {
func (m *roachmart) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(m, m.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(m, m.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -218,7 +218,7 @@ func (m *roachmart) Ops(
db.SetMaxOpenConns(m.connFlags.Concurrency + 1)
db.SetMaxIdleConns(m.connFlags.Concurrency + 1)

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}

const query = `SELECT * FROM orders WHERE user_zone = $1 AND user_email = $2`
for i := 0; i < m.connFlags.Concurrency; i++ {
Expand Down
3 changes: 1 addition & 2 deletions pkg/workload/bank/bank.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (b *bank) Tables() []workload.Table {
func (b *bank) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(b, b.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(b, b.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -205,7 +205,6 @@ func (b *bank) Ops(
}

ql := workload.QueryLoad{
SQLDatabase: sqlDatabase,
Close: func(_ context.Context) error {
return db.Close()
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/bulkingest/bulkingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func (w *bulkingest) Tables() []workload.Table {
func (w *bulkingest) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -204,7 +204,7 @@ func (w *bulkingest) Ops(
return workload.QueryLoad{}, err
}

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < w.connFlags.Concurrency; i++ {
rng := rand.New(rand.NewSource(RandomSeed.Seed()))
hists := reg.GetHandle()
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/indexes/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (w *indexes) Tables() []workload.Table {
func (w *indexes) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -188,7 +188,7 @@ func (w *indexes) Ops(
return workload.QueryLoad{}, errors.Errorf("unknown workload: %q", w.workload)
}

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < w.connFlags.Concurrency; i++ {
op := &indexesOp{
config: w,
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/insights/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (b *insights) Tables() []workload.Table {
func (b *insights) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(b, b.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(b, b.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -226,7 +226,7 @@ func (b *insights) Ops(
db.SetMaxOpenConns(b.connFlags.Concurrency + 1)
db.SetMaxIdleConns(b.connFlags.Concurrency + 1)

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
rng := rand.New(rand.NewSource(RandomSeed.Seed()))

// Most of the insight queries are slow by design. This prevents them from
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/jsonload/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (w *jsonLoad) Tables() []workload.Table {
func (w *jsonLoad) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -191,7 +191,7 @@ func (w *jsonLoad) Ops(
return workload.QueryLoad{}, err
}

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < w.connFlags.Concurrency; i++ {
op := jsonOp{
config: w,
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ func (w *kv) Tables() []workload.Table {
func (w *kv) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -537,7 +537,7 @@ func (w *kv) Ops(
delStmtStr := buf.String()

gen, _, kt, _ := w.createKeyGenerator()
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
var numEmptyResults atomic.Int64
for i := 0; i < w.connFlags.Concurrency; i++ {
op := &kvOp{
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/ledger/ledger.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (w *ledger) Tables() []workload.Table {
func (w *ledger) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -195,7 +195,7 @@ func (w *ledger) Ops(
db.SetMaxIdleConns(w.connFlags.Concurrency + 1)

w.reg = reg
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
now := timeutil.Now().UnixNano()
for i := 0; i < w.connFlags.Concurrency; i++ {
worker := &worker{
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/movr/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,11 +303,11 @@ func (m *movr) Ops(
m.fakerOnce.Do(func() {
m.faker = faker.NewFaker()
})
sqlDatabase, err := workload.SanitizeUrls(m, m.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(m, m.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
db, err := workload.NewRoundRobinDB(urls)
if err != nil {
return workload.QueryLoad{}, err
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/querybench/query_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (*queryBench) Tables() []workload.Table {
func (g *queryBench) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(g, g.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(g, g.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -143,7 +143,7 @@ func (g *queryBench) Ops(
maxNumStmts = g.numRunsPerQuery * len(stmts)
}

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < g.connFlags.Concurrency; i++ {
op := queryBenchWorker{
hists: reg.GetHandle(),
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/querylog/querylog.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func (w *querylog) Hooks() workload.Hooks {
func (w *querylog) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func (w *querylog) Ops(
if err != nil {
return workload.QueryLoad{}, err
}
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
if w.querybenchPath != `` {
conn, err := pgx.ConnectConfig(ctx, connCfg)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/queue/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (w *queue) Tables() []workload.Table {
func (w *queue) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (w *queue) Ops(

seqFunc := makeSequenceFunc()

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < w.connFlags.Concurrency; i++ {
op := queueOp{
workerID: i + 1,
Expand Down
6 changes: 3 additions & 3 deletions pkg/workload/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func typeForOid(db *gosql.DB, typeOid oid.Oid, tableName, columnName string) (*t
func (w *random) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (ql workload.QueryLoad, retErr error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -289,7 +289,7 @@ AND i.indisprimary`, relid)
}
}

fmt.Fprintf(&buf, `%s INTO %s.%s (`, dmlMethod, tree.NameString(sqlDatabase), tree.NameString(tableName))
fmt.Fprintf(&buf, `%s INTO %s (`, dmlMethod, tree.NameString(tableName))
for i, c := range nonComputedCols {
if i > 0 {
buf.WriteString(",")
Expand Down Expand Up @@ -320,7 +320,7 @@ AND i.indisprimary`, relid)
return workload.QueryLoad{}, err
}

ql = workload.QueryLoad{SQLDatabase: sqlDatabase}
ql = workload.QueryLoad{}

for i := 0; i < w.connFlags.Concurrency; i++ {
op := randOp{
Expand Down
3 changes: 1 addition & 2 deletions pkg/workload/schemachange/schemachange.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (s *schemaChange) Ops(
ctx, span := tracer.Start(ctx, "schemaChange.Ops")
defer func() { EndSpan(span, err) }()

sqlDatabase, err := workload.SanitizeUrls(s, s.connFlags.DBOverride, urls)
_, err = workload.SanitizeUrls(s, s.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -254,7 +254,6 @@ func (s *schemaChange) Ops(
}

ql := workload.QueryLoad{
SQLDatabase: sqlDatabase,
Close: func(_ context.Context) error {
// Create a new context for shutting down the tracer provider. The
// provided context may be cancelled depending on why the workload is
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/sqlsmith/sqlsmith.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (g *sqlSmith) Ops(
if err := g.validateErrorSetting(); err != nil {
return workload.QueryLoad{}, err
}
sqlDatabase, err := workload.SanitizeUrls(g, g.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(g, g.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -146,7 +146,7 @@ func (g *sqlSmith) Ops(
db.SetMaxOpenConns(g.connFlags.Concurrency + 1)
db.SetMaxIdleConns(g.connFlags.Concurrency + 1)

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < g.connFlags.Concurrency; i++ {
rng := rand.New(rand.NewSource(RandomSeed.Seed() + int64(i)))
smither, err := sqlsmith.NewSmither(db, rng)
Expand Down
3 changes: 1 addition & 2 deletions pkg/workload/sqlstats/sqlstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func genPermutations() *gen {
func (s *sqlStats) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(s, s.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(s, s.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -150,7 +150,6 @@ func (s *sqlStats) Ops(
gen := genPermutations()

ql := workload.QueryLoad{
SQLDatabase: sqlDatabase,
Close: func(_ context.Context) error {
return db.Close()
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/tpcc/tpcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ func (w *tpcc) Ops(
w.txCounters = setupTPCCMetrics(reg.Registerer())
}

sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -830,7 +830,7 @@ func (w *tpcc) Ops(
}
}
fmt.Printf("Initializing %d workers and preparing statements...\n", w.workers)
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
ql.WorkerFns = make([]func(context.Context) error, 0, w.workers)
var group errgroup.Group

Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/tpccchecks/checks_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (*tpccChecks) Meta() workload.Meta {
func (w *tpccChecks) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, errors.Wrapf(err, "could not sanitize urls %v", urls)
}
Expand All @@ -117,7 +117,7 @@ func (w *tpccChecks) Ops(
dbs[i].SetMaxOpenConns(3 * w.concurrency)
dbs[i].SetMaxIdleConns(3 * w.concurrency)
}
ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
ql.WorkerFns = make([]func(context.Context) error, w.concurrency)
checks, err := filterChecks(tpcc.AllChecks(), w.checks)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/tpcds/tpcds.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (w *tpcds) Tables() []workload.Table {
func (w *tpcds) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -276,7 +276,7 @@ func (w *tpcds) Ops(
db.SetMaxOpenConns(w.connFlags.Concurrency + 1)
db.SetMaxIdleConns(w.connFlags.Concurrency + 1)

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < w.connFlags.Concurrency; i++ {
worker := &worker{
config: w,
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/tpch/tpch.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (w *tpch) Tables() []workload.Table {
func (w *tpch) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(w, w.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand All @@ -310,7 +310,7 @@ func (w *tpch) Ops(
db.SetMaxOpenConns(w.connFlags.Concurrency + 1)
db.SetMaxIdleConns(w.connFlags.Concurrency + 1)

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for i := 0; i < w.connFlags.Concurrency; i++ {
worker := &worker{
config: w,
Expand Down
4 changes: 2 additions & 2 deletions pkg/workload/ttllogger/ttllogger.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var logChars = []rune("abdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ !.")
func (l *ttlLogger) Ops(
ctx context.Context, urls []string, reg *histogram.Registry,
) (workload.QueryLoad, error) {
sqlDatabase, err := workload.SanitizeUrls(l, l.connFlags.DBOverride, urls)
_, err := workload.SanitizeUrls(l, l.connFlags.DBOverride, urls)
if err != nil {
return workload.QueryLoad{}, err
}
Expand Down Expand Up @@ -118,7 +118,7 @@ func (l *ttlLogger) Ops(
return workload.QueryLoad{}, errors.Newf("concurrency must be divisible by 2")
}

ql := workload.QueryLoad{SQLDatabase: sqlDatabase}
ql := workload.QueryLoad{}
for len(ql.WorkerFns) < l.connFlags.Concurrency {
rng := rand.New(rand.NewSource(l.seed + int64(len(ql.WorkerFns))))
hists := reg.GetHandle()
Expand Down
2 changes: 0 additions & 2 deletions pkg/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ func (l requiresCCLBinaryDataLoader) InitialDataLoad(
// QueryLoad represents some SQL query workload performable on a database
// initialized with the requisite tables.
type QueryLoad struct {
SQLDatabase string

// WorkerFns is one function per worker. It is to be called once per unit of
// work to be done.
WorkerFns []func(context.Context) error
Expand Down
Loading

0 comments on commit 87590cc

Please sign in to comment.