perf: batch INSERT for SQLite append_events #362

Open
opened 2026-04-12 11:56:08 -07:00 by jwilger-ai-bot · 0 comments
jwilger-ai-bot commented 2026-04-12 11:56:08 -07:00 (Migrated from github.com)

Problem

SqliteEventStore::append_events() runs a separate INSERT statement per event inside a transaction, similar to the PostgreSQL backend.

Proposed Solution

Replace the per-event INSERT loop with a single multi-row INSERT statement. SQLite supports INSERT INTO ... VALUES (...), (...), (...) syntax.

Expected Impact

Moderate improvement on larger batches. Less impactful than the PostgreSQL optimization since SQLite is in-process (no network round-trip per statement), but reducing statement preparation overhead should still help.

Location

eventcore-sqlite/src/lib.rsappend_events() method.

Benchmark Baseline

Run cargo bench -p eventcore-bench --bench store_operations -- 'store/append/sqlite' to measure before/after.

## Problem `SqliteEventStore::append_events()` runs a separate INSERT statement per event inside a transaction, similar to the PostgreSQL backend. ## Proposed Solution Replace the per-event INSERT loop with a single multi-row INSERT statement. SQLite supports `INSERT INTO ... VALUES (...), (...), (...)` syntax. ## Expected Impact Moderate improvement on larger batches. Less impactful than the PostgreSQL optimization since SQLite is in-process (no network round-trip per statement), but reducing statement preparation overhead should still help. ## Location `eventcore-sqlite/src/lib.rs` — `append_events()` method. ## Benchmark Baseline Run `cargo bench -p eventcore-bench --bench store_operations -- 'store/append/sqlite'` to measure before/after.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jwilger/eventcore#362
No description provided.