Skip to content

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

Turso 10 min read Deep dive mediumAdept

Turso Sync: Local-First SQLite with Push and Pull

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.

Assumes: SQLite basicswrite-ahead loggingchange data capture

Related posts

  • Turso Sync: a much, much, much better way to sync

    Turso mediumAdept

    Turso, a Rust rewrite of SQLite, replaces libSQL's Embedded Replicas with a sync model built on change data capture, shipping logical changes instead of physical pages and splitting sync into separate push() and pull() operations. Page-based replication wasted bandwidth, could not resolve conflicts (so writes defaulted to the remote), and diverged around checkpoints, forcing re-bootstraps. In Node.js benchmarks against Turso Cloud, Turso sync was 8.9x faster with 16.3x less traffic for 3,000 sequential inserts, 312x faster for read-your-writes cycles with local writes (7.3x even when pushing after every write), and 2.1x faster for an initial pull. Turso also supports partial, lazy bootstrap, and the recommendation is to switch from libSQL sync to Turso.

  • Building Local-First Apps: The Complete Guide to Offline-First Database Sync

    Turso mediumAdept

    Turso Sync brings local-first behaviour to SQLite-based apps. Local changes are captured via change data capture and pushed as logical row-level mutations, while remote changes are pulled as physical pages so replicas converge byte-for-byte. Turso's benchmarks report up to 312x faster syncs and roughly 18x less traffic than the older Embedded Replicas approach. The guide covers TypeScript setup with background push/pull loops, Last-Push-Wins conflict resolution and a transform hook for custom merges such as turning sets into increments, scoped auth tokens and JWKS, sync-aware WAL checkpointing, and experimental partial sync. It also notes that there is no CRDT or peer-to-peer support, which makes the approach a poor fit for real-time collaborative document editing.

  • Introducing Databases Anywhere with Turso Sync

    Turso mediumAdept

    Turso Sync lets local SQLite-compatible Turso databases, in Node or in the browser via WASM, sync with Turso Cloud through push, pull and sync-aware checkpoint methods layered on the standard database API. Local changes are pushed as row-level logical mutations with Last-Push-Wins conflict resolution, and a transform hook lets developers rewrite mutations for custom merge logic. Remote changes are pulled as physical pages, so replicas converge byte-for-byte on the cloud source of truth, which rules out peer-to-peer sync. The launch also adds per-table, per-operation token permissions and external JWKS/OIDC auth (Clerk and Auth0 in beta).

  • Introducing Offline Writes for Turso

    Turso easyNovice

    Turso is opening a private beta for Offline Writes, letting applications write to local embedded SQLite replicas while online or offline and sync those changes to the cloud later. Local writes land in the SQLite write-ahead log, and sync pushes or pulls WAL frames to and from the remote database. Conflict handling stays simple and assumes mostly serialized writers: the first push wins, and the others pick a strategy such as fail-on-conflict, discard-local, rebase-local or a custom resolver. The pitch is that pairing this with a database-per-user design makes local-first apps simpler, because the whole database syncs rather than a selected subset.

  • How Turso made connections to SQLite databases 575x faster

    Turso mediumAdept

    SQLite re-reads and parses the sqlite_schema table on every new connection, so opening a connection to a database with 10,000 tables takes about 23ms. Turso, a Rust rewrite of SQLite, parses the schema once and shares it across connections in the same process. It uses Arc::make_mut copy-on-write, so a connection only clones the schema when it changes it inside a transaction, and committed changes propagate to all connections. New connections then open in about 40 microseconds no matter how many tables exist, which is faster even than SQLite's 130 microseconds for a single-table database.

The quest for software engineering knowledge.

Look:
Layout: