Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Turso 3 min read How-to mediumAdept

Batches in SQLite

Batching SQL statements into a single request cuts latency sharply for remote SQLite via libSQL/Turso, where every query is a network round trip. A test with the libSQL Rust SDK showed about 5.3s for looping through 10 queries versus 1.7s for one batch of 1000 inserts. Batches are atomic, either committing all changes or rolling back, and can sequence dependent statements without the write locks that make interactive transactions prone to SQLITE_BUSY errors under high latency. Batches are the recommended replacement for loops that issue many queries.

Related posts

  • Turso 0.8: Concurrent writes without SQLite's single-writer bottleneck

    Turso mediumAdept

    Turso 0.8 targets SQLite's single-writer bottleneck with BEGIN CONCURRENT, an MVCC mode where transactions start independently and commit in groups. At 1,000 TPS with Poisson arrivals, p99.9 latency is 2.4 ms at 32 connections versus 1.2 s for SQLite, whose lock-retry sleeps inflate tail latency. On disjoint-key inserts, Turso scales to about 9,500 TPS at 64 connections while SQLite stays near 1,370 TPS, though SQLite is faster with a single connection. The release also adds full window function and recursive CTE support, MVCC-compatible full-text search, and optimizer work including correlated subquery unnesting, hash joins and JSON EXPLAIN QUERY PLAN output.

  • Turso v0.7.0

    Turso hardMaster

    Turso 0.7 drops the beta label and focuses on performance and robustness for embedded, multi-tenant use: the core no longer blocks on I/O, yields CPU via a new StepResult::Yield, moves to fallible allocation so OOM surfaces as an error, and treats the page cache as a soft limit like SQLite. The MVCC engine gets a linear-merge dual cursor that replaces per-row skiplist lookups (about a quarter of CPU time on write-heavy loads), watermark-driven garbage collection, experimental passive checkpoints that don't stop the world, and smaller row versions. SQL additions include PostgreSQL-style sequences (now backing AUTOINCREMENT), ICU collations, REINDEX, ordered-set aggregates and window-function groundwork. The SDKs gain a SQLite-compatible .NET/EF Core provider, GIL release and FTS in Python, and concurrent transactions in JavaScript.

  • High-Throughput OLTP in Three Simple Steps

    TigerBeetle mediumAdept

    Migrating a TPC-B-style bank workload (accounts, tellers, branches, history) from a general-purpose SQL model to TigerBeetle yields roughly 100x throughput when three techniques are applied: modeling each transaction as linked debit/credit transfers with an aggregate account, relying on batching instead of client concurrency, and using monotonic time-based IDs. TigerBeetle clients allow one outstanding request and automatically batch operations (up to 8,189 per request) while waiting, so many goroutines sharing one thread-safe client reach about 454k transactions (909k transfers) per second, whereas adding more clients does not help. Random UUID transfer IDs force index lookups for idempotency checks, while ULID-like TBIDs make the check a cheap monotonicity comparison. A relational database with stored procedures reached about 7k TPS in the same comparison, a gap attributed to avoiding row-level locks, batched execution and parallel server I/O.

  • Bringing SQLite to Vercel Functions with Turso

    Turso mediumAdept

    Turso's partial sync replicates a subset of SQLite database pages into Vercel Functions so reads run in-process with no network round-trip, while writes go to the remote Turso database for durability and consistency. On cold start the driver fetches the first 128 KiB of the SQLite file, then pulls further 128 KiB segments on demand into the ephemeral /tmp directory, so cold-start cost scales with the working set rather than total database size. The experimental @tursodatabase/vercel-experimental package also auto-provisions databases by name for database-per-tenant or per-agent-session patterns. It offers an optional local-write batching mode that trades consistency for lower write latency, and uses a waitUntil() safety net that pushes pending changes if close() is forgotten.

  • Turso Sync: Local-First SQLite with Push and Pull

    Turso mediumAdept

    Turso Sync replaces libSQL's page-based Embedded Replicas with logical row-level changes captured via CDC in Turso Database, a Rust rewrite of SQLite, so reads and writes stay local and apps call push() and pull() explicitly. Shipping logical statements instead of WAL pages lets unrelated writes merge on the server. Experimental partial sync fetches 128 KiB segments on demand, with optional prefetch. Benchmarks show roughly 7–10x speedups and about 15x less data for small-write workloads, but only 1.2x when writes are already batched. Conflicts resolve by last-push-wins, which suits single-writer data but loses updates on shared counters unless data is modeled append-only.

The quest for software engineering knowledge.

Look:
Layout: