Skip to content

Commit

Permalink
colbuilder: add benchmark for nested AND expression planning
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
yuzefovich committed Jul 21, 2023
1 parent 72341d3 commit 446fe5e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions pkg/sql/colexec/colbuilder/execplan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,36 @@ func BenchmarkRenderPlanning(b *testing.B) {
}
}
}

// BenchmarkNestedAndPlanning benchmarks how long it takes to run a query with
// many expressions logically AND'ed in a single output column.
func BenchmarkNestedAndPlanning(b *testing.B) {
defer leaktest.AfterTest(b)()
defer log.Scope(b).Close(b)

ctx := context.Background()
s, db, _ := serverutils.StartServer(b, base.TestServerArgs{SQLMemoryPoolSize: 10 << 30})
defer s.Stopper().Stop(ctx)

sqlDB := sqlutils.MakeSQLRunner(db)
// Disable fallback to the row-by-row processing wrapping.
sqlDB.Exec(b, "SET CLUSTER SETTING sql.distsql.vectorize_render_wrapping.min_render_count = 9999999")
sqlDB.Exec(b, "CREATE TABLE bench (i INT)")
for _, numRenders := range []int{1 << 4, 1 << 8, 1 << 12} {
var sb strings.Builder
sb.WriteString("SELECT ")
for i := 0; i < numRenders; i++ {
if i > 0 {
sb.WriteString(" AND ")
}
sb.WriteString(fmt.Sprintf("i < %d", i+1))
}
sb.WriteString(" FROM bench")
query := sb.String()
b.Run(fmt.Sprintf("renders=%d", numRenders), func(b *testing.B) {
for i := 0; i < b.N; i++ {
sqlDB.Exec(b, query)
}
})
}
}

0 comments on commit 446fe5e

Please sign in to comment.