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

Conversation

rusher
Copy link
Contributor

@rusher rusher commented Apr 22, 2025

Description

created only a benchmark addition for #1697

Checklist

  • Code compiles correctly
  • Created tests which fail without the change (if possible)
  • All tests passing
  • Extended the README / documentation, if necessary
  • Added myself / the copyright holder to the AUTHORS file

Summary by CodeRabbit

  • Tests
    • Added a new benchmark to measure performance when selecting 10,000 rows from a sequence table in MariaDB.

Sorry, something went wrong.

Copy link

coderabbitai bot commented Apr 22, 2025

Walkthrough

A new benchmark function, BenchmarkSelect10000rows, has been introduced in the benchmark_test.go file. This benchmark connects to a database, verifies that the server is MariaDB, and if so, repeatedly queries all rows from the seq_1_to_10000 table, scanning each row. The benchmark is skipped for non-MariaDB servers and fails immediately on any errors encountered during execution. No existing code or benchmarks were modified.

Changes

File(s) Change Summary
benchmark_test.go Added BenchmarkSelect10000rows to benchmark selecting and scanning all rows from a test table.

Poem

In the garden of code, a new test takes root,
Rows by the thousands, the benchmark in pursuit.
MariaDB’s the gate, only it lets you through—
Scan each little carrot, see how fast you chew!
With paws on the timer, we hop and we race,
Counting each veggie, in this database chase.
🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6a958 and e229508.

📒 Files selected for processing (1)
  • benchmark_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • benchmark_test.go
⏰ Context from checks skipped due to timeout of 90000ms (19)
  • GitHub Check: test (windows-latest, 1.24, mariadb-10.6)
  • GitHub Check: test (windows-latest, 1.24, 8.4)
  • GitHub Check: test (ubuntu-latest, 1.23, 9.0)
  • GitHub Check: test (windows-latest, 1.24, mariadb-10.5)
  • GitHub Check: test (windows-latest, 1.24, mariadb-11.4)
  • GitHub Check: test (windows-latest, 1.24, mariadb-10.11)
  • GitHub Check: test (macos-latest, 1.24, 8.0)
  • GitHub Check: test (windows-latest, 1.24, 8.0)
  • GitHub Check: test (macos-latest, 1.24, mariadb-10.6)
  • GitHub Check: test (windows-latest, 1.24, 9.0)
  • GitHub Check: test (macos-latest, 1.24, 9.0)
  • GitHub Check: test (windows-latest, 1.24, mariadb-11.2)
  • GitHub Check: test (ubuntu-latest, 1.24, mariadb-11.4)
  • GitHub Check: test (windows-latest, 1.24, 5.7)
  • GitHub Check: test (macos-latest, 1.24, mariadb-10.11)
  • GitHub Check: test (windows-latest, 1.24, mariadb-11.1)
  • GitHub Check: test (ubuntu-latest, 1.24, mariadb-11.2)
  • GitHub Check: test (ubuntu-latest, 1.24, 8.4)
  • GitHub Check: test (macos-latest, 1.24, mariadb-11.1)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@rusher rusher mentioned this pull request Apr 22, 2025
5 tasks
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
benchmark_test.go (1)

116-155: Good addition of the benchmark for large result sets.

The new benchmark effectively tests the performance of retrieving and scanning a large number of rows, which is a valuable addition to the benchmark suite. This will help track driver performance for large result set processing.

A few suggestions for improvement:

  1. Add b.ReportAllocs() before b.StartTimer() to report memory allocations (consistent with other benchmarks in this file).
  2. Add a check for rows.Err() after the scanning loop to catch any errors that occurred during iteration.
  3. Consider adding a brief comment explaining the benchmark's purpose and the dependency on MariaDB's seq_1_to_10000 table.
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.ReportAllocs()
	b.StartTimer()
	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 n := 0; n < b.N; 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)
			}
		}
+		if err = rows.Err(); err != nil {
+			rows.Close()
+			b.Fatalf("Error during row iteration: %v", err)
+		}
		rows.Close()
	}
	b.StopTimer()
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7da50ff and 5f6a958.

📒 Files selected for processing (1)
  • benchmark_test.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (18)
  • GitHub Check: test (macos-latest, 1.24, mariadb-10.11)
  • GitHub Check: test (windows-latest, 1.24, mariadb-10.6)
  • GitHub Check: test (macos-latest, 1.24, mariadb-11.4)
  • GitHub Check: test (macos-latest, 1.24, mariadb-11.2)
  • GitHub Check: test (ubuntu-latest, 1.22, 9.0)
  • GitHub Check: test (windows-latest, 1.24, mariadb-10.11)
  • GitHub Check: test (macos-latest, 1.24, 8.0)
  • GitHub Check: test (windows-latest, 1.24, 5.7)
  • GitHub Check: test (windows-latest, 1.24, 9.0)
  • GitHub Check: test (windows-latest, 1.24, mariadb-10.5)
  • GitHub Check: test (windows-latest, 1.24, mariadb-11.2)
  • GitHub Check: test (windows-latest, 1.24, 8.4)
  • GitHub Check: test (windows-latest, 1.24, mariadb-11.4)
  • GitHub Check: test (macos-latest, 1.24, mariadb-11.1)
  • GitHub Check: test (ubuntu-latest, 1.24, mariadb-10.5)
  • GitHub Check: test (windows-latest, 1.24, mariadb-11.1)
  • GitHub Check: test (windows-latest, 1.24, 8.0)
  • GitHub Check: test (ubuntu-latest, 1.24, 5.7)

@coveralls
Copy link

coveralls commented Apr 22, 2025

Coverage Status

coverage: 82.833%. remained the same
when pulling e229508 on rusher:read_opt
into 7da50ff on go-sql-driver:master.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
@methane
Copy link
Member

methane commented Apr 23, 2025

Sorry. I missed there is BenchmarkReceiveMassiveRows already.
I improve it instead of adding similar bench.

@methane methane closed this Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants