-
-
Notifications
You must be signed in to change notification settings - Fork 35
feat(db)!: add bulk_insert
#414
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements bulk insert functionality for the database layer, providing significant performance improvements for inserting multiple model instances. The implementation includes support for all database backends (PostgreSQL, MySQL, SQLite) with appropriate optimizations for each.
- Added
bulk_createmethod to theModeltrait and correspondingbulk_insert/bulk_insert_or_updatemethods to the database backend - Implemented smart batching based on database parameter limits (32,766 for SQLite, 65,535 for PostgreSQL/MySQL)
- Comprehensive test coverage including edge cases (empty input, large batches, models with only auto fields, fixed primary keys)
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| cot/src/db.rs | Implements bulk insert functionality with database-specific optimizations, adds new error types for bulk operations, and provides both insert and upsert variants |
| cot/tests/db.rs | Adds 5 comprehensive test cases covering basic functionality, empty input handling, large batch processing, edge cases with auto-only fields, and fixed primary key scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
| Branch | bulk-create |
| Testbed | github-ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| empty_router/empty_router | 📈 view plot 🚷 view threshold | 6,117.00 µs(+0.69%)Baseline: 6,075.03 µs | 6,676.54 µs (91.62%) |
| json_api/json_api | 📈 view plot 🚷 view threshold | 1,032.80 µs(+0.58%)Baseline: 1,026.88 µs | 1,113.56 µs (92.75%) |
| nested_routers/nested_routers | 📈 view plot 🚷 view threshold | 952.16 µs(+0.13%)Baseline: 950.91 µs | 1,032.73 µs (92.20%) |
| single_root_route/single_root_route | 📈 view plot 🚷 view threshold | 913.18 µs(+0.31%)Baseline: 910.35 µs | 980.49 µs (93.14%) |
| single_root_route_burst/single_root_route_burst | 📈 view plot 🚷 view threshold | 17,884.00 µs(+0.42%)Baseline: 17,808.50 µs | 21,177.16 µs (84.45%) |
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
seqre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, please apply Copilot review as it's actually not bad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 11 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
seqre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.