Skip to content

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

Turso 5 min read Announcement mediumAdept

Introducing Change Data Capture for SQLite in Turso

Turso's SQLite rewrite gains an unstable, built-in Change Data Capture feature enabled per connection via PRAGMA unstable_capture_data_changes_conn. The pragma logs every insert, update and delete into a regular turso_cdc table with change type, rowid and binary before/after row images, and JSON helper functions decode those images. Four modes (id, before, after, full) trade detail against storage. Decoding uses the current schema, so dropped or added columns can corrupt historical records unless schema versions are tracked manually. Release v0.1.2 also adds Euclidean vector distance, new language bindings, B-tree lookup optimizations and fault-injection and Antithesis testing.

Assumes: SQLite basicschange data capture concept

Related posts

  • Change Data Capture in SQLite, Without the Triggers

    Turso mediumAdept

    Turso Database, a Rust rewrite of SQLite, has built-in change data capture enabled with a single PRAGMA. It records every committed insert, update, delete and schema change into a regular `turso_cdc` table with transaction IDs, before/after row images and commit markers, so no triggers or WAL decoding are needed. The post compares this to trigger-based sqlite-cdc, the session extension and update hooks, and lists rough edges: decoding uses the current schema, the change table grows until pruned, and capture is per connection. It ends with a restart-safe polling consumer that groups changes by transaction, advances a watermark only at transaction boundaries, needs an idempotent apply step and prunes against the slowest consumer.

  • 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.

  • Turso v0.4.0

    Turso mediumAdept

    Turso v0.4.0 overhauls its experimental MVCC mode, which lifts SQLite's single-writer limit, adding index support, checkpointing and recovery. MVCC is now enabled with `PRAGMA journal_mode = 'experimental_mvcc'`, persisted in the file header, and makes the file unreadable by stock SQLite until you switch back to WAL. Partial sync fetches pages on demand, with bootstrap queries and prefetching (persistent mode is Linux-only because it needs sparse files), and sync now ships in the Python and Go SDKs. The release also adds page cache spilling for large queries, ANALYZE support for better join ordering, and a disk-spilling hash join for non-indexed columns in place of SQLite's ephemeral B-tree indexes.

  • Turso v0.6.0

    Turso mediumAdept

    Turso 0.6 is the first release supporting all major SQLite features, adding experimental multi-process WAL access (OFD locks on Linux, fcntl elsewhere, IOCP on Windows) and VACUUM/VACUUM INTO. SQL additions include production-ready triggers, temp tables, virtual generated columns, CREATE TABLE AS SELECT, partial WITHOUT ROWID support, UPDATE...FROM, FILTER on aggregates, NULLS FIRST/LAST, and INDEXED BY hints. The STRICT type system gains arrays, structs/unions and Postgres-style domains, and MVCC logical logs are now encrypted with AEAD in 32 KiB chunks. SDK changes add query timeouts, async prepare, fixed interactive transactions in the serverless driver, an npm-distributed CLI and a SQLAlchemy asyncio dialect.

  • 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: