mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
fix(memory): move to batch insert (#3122)
# Improve LibSQL Performance and Add Web Client Support ## Changes ### 1. Replace Transaction with Batch Operations in `saveMessages` The previous implementation used transactions for saving messages, which caused performance issues when using LibSQL over the wire. This was problematic because: - SQLite locks the database for writes until the transaction is committed - With remote databases, each insert inside the transaction takes longer - The database remains locked for writes during this entire period The new implementation uses batch operations instead, which: - Sends multiple statements at once (up to 5MB of data per batch) - Significantly improves performance for remote databases - Reduces database lock time https://developers.cloudflare.com/workers/tutorials/connect-to-turso-using-workers/ --------- Signed-off-by: Marcos Candeia <marrcooos@gmail.com> Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com> Co-authored-by: Ward Peeters <ward@coding-tech.com>
This commit is contained in:
parent
96dbec2291
commit
56c31b75c1
2 changed files with 28 additions and 17 deletions
Loading…
Add table
Add a link
Reference in a new issue