perf: cache prepared SQL statements #6

Merged
jperera merged 1 commit from perf/cache-prepared-statements into main 2026-04-02 20:35:09 +02:00
Owner

Summary

  • Adds a stmt() helper that caches prepared statements by SQL string, eliminating query recompilation on every call
  • Consolidates 6 separate exec() calls in initDB() into a single call
  • Clears the statement cache in closeDB() and after initDB()

Impact

Every function that queries the database (getStations, getLatestPrices, getPriceHistory, savePricesBatch, etc.) now reuses its prepared statement instead of creating a new one on each invocation. This avoids SQLite query parsing overhead on every request.

## Summary - Adds a `stmt()` helper that caches prepared statements by SQL string, eliminating query recompilation on every call - Consolidates 6 separate `exec()` calls in `initDB()` into a single call - Clears the statement cache in `closeDB()` and after `initDB()` ## Impact Every function that queries the database (`getStations`, `getLatestPrices`, `getPriceHistory`, `savePricesBatch`, etc.) now reuses its prepared statement instead of creating a new one on each invocation. This avoids SQLite query parsing overhead on every request.
- Add stmt() helper that caches prepared statements by SQL string,
  avoiding recompilation on every query call
- Consolidate 6 separate exec() calls in initDB() into a single call
- Clear statement cache in closeDB() and after initDB()
jperera force-pushed perf/cache-prepared-statements from 8e52b6e9c0 to bb9da51aec 2026-04-02 20:35:02 +02:00 Compare
jperera deleted branch perf/cache-prepared-statements 2026-04-02 20:35:10 +02:00
Sign in to join this conversation.
No reviewers
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
jperera/gasolineras!6
No description provided.