Skip to content

adding benchmark query with lots of rows #1703

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,46 @@ func benchmarkQueryHelper(b *testing.B, compr bool) {
}
}

func BenchmarkSelect10000rows(b *testing.B) {
db := initDB(b, false)
defer db.Close()

// Check if we're using MariaDB
var version string
err := db.QueryRow("SELECT @@version").Scan(&version)
if err != nil {
b.Fatalf("Failed to get server version: %v", err)
}

if !strings.Contains(strings.ToLower(version), "mariadb") {
b.Skip("Skipping benchmark as it requires MariaDB sequence table")
return
}

b.ResetTimer()
stmt, err := db.Prepare("SELECT * FROM seq_1_to_10000")
if err != nil {
b.Fatalf("Failed to prepare statement: %v", err)
}
defer stmt.Close()
for range b.N {
rows, err := stmt.Query()
if err != nil {
b.Fatalf("Failed to query 10000rows: %v", err)
}

var id int64
for rows.Next() {
err = rows.Scan(&id)
if err != nil {
rows.Close()
b.Fatalf("Failed to scan row: %v", err)
}
}
rows.Close()
}
}

func BenchmarkExec(b *testing.B) {
tb := (*TB)(b)
b.StopTimer()
Expand Down