Draft
Conversation
Collaborator
Author
|
im wondering if the sqlalchemy write part does something it feels weird that it would be faster than the base driver ❯ python scripts/bench.py --driver asyncpg --driver sqlite
Running benchmark for driver: asyncpg
Running benchmark for driver: sqlite
Benchmark Results
┏━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┓
┃ Driver ┃ Library ┃ Scenario ┃ Time (s) ┃ % Slower vs Raw ┃
┡━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━━━━━┩
│ asyncpg │ raw │ initialization │ 0.0497 │ — │
│ asyncpg │ sqlspec │ initialization │ 0.0977 │ 96.6% │
│ asyncpg │ sqlalchemy │ initialization │ 0.0329 │ -33.7% │
│ asyncpg │ raw │ write_heavy │ 51.8678 │ — │
│ asyncpg │ sqlspec │ write_heavy │ 56.8252 │ 9.6% │
│ asyncpg │ sqlalchemy │ write_heavy │ 4.5475 │ -91.2% │
│ asyncpg │ raw │ read_heavy │ 0.0721 │ — │
│ asyncpg │ sqlspec │ read_heavy │ 0.1858 │ 157.8% │
│ asyncpg │ sqlalchemy │ read_heavy │ 0.1080 │ 49.9% │
│ sqlite │ raw │ initialization │ 0.0007 │ — │
│ sqlite │ sqlspec │ initialization │ 0.0029 │ 343.8% │
│ sqlite │ sqlalchemy │ initialization │ 0.0043 │ 555.7% │
│ sqlite │ raw │ write_heavy │ 0.0594 │ — │
│ sqlite │ sqlspec │ write_heavy │ 2.5934 │ 4269.5% │
│ sqlite │ sqlalchemy │ write_heavy │ 0.7772 │ 1209.4% │
│ sqlite │ raw │ read_heavy │ 0.0804 │ — │
│ sqlite │ sqlspec │ read_heavy │ 2.5633 │ 3087.9% │
│ sqlite │ sqlalchemy │ read_heavy │ 0.7890 │ 881.2% │
└─────────┴────────────┴────────────────┴──────────┴─────────────────┘
Benchmarks complete for drivers: asyncpg, sqlite |
cofin
pushed a commit
that referenced
this pull request
Feb 4, 2026
Add comprehensive benchmark tooling originally contributed by euri10 in PR #354, with enhancements for testing query cache effectiveness. Scenarios: - initialization: Connection and table setup overhead - write_heavy: Bulk insert performance (execute_many) - read_heavy: Bulk read with fetchall - repeated_queries: Single-row queries with varying params (tests _qc_*) Compares: raw driver vs sqlspec vs SQLAlchemy Drivers: sqlite (asyncpg requires PostgreSQL server) Usage: uv run python scripts/bench.py --driver sqlite --rows 10000 Co-authored-by: euri10 <benoit.barthelet@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wip, trying to figure out if reads are indeed weirdly slow