Skip to content

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

Turso 7 min read Deep dive mediumAdept

Beyond FTS5: Building Transactional Full-Text Search in TursoDB

TursoDB adds native full-text search by embedding Tantivy and implementing its Directory trait on top of Turso's B-tree, storing index "files" as 512KB chunks in an internal table. Because of this design, index updates share the SQL transaction, WAL, rollback and single-file storage, and indexes are created with Postgres-style `CREATE INDEX ... USING fts` syntax with configurable tokenizers, BM25 column weights, MATCH and highlighting. A hybrid cache keeps metadata resident, caches hot small files (term dictionaries, fast fields) whole, and lazy-loads large segment data by chunk. Background merges conflict with single-writer transactional storage, so automatic merging is disabled via NoMergePolicy. An explicit `OPTIMIZE INDEX` command handles compaction, similar to VACUUM or ANALYZE.

Related posts

  • Turso v0.5.0

    Turso hardMaster

    Turso v0.5.0 promotes MVCC-based concurrent writes (BEGIN CONCURRENT, adapted from Hekaton) to beta. The MVCC work adds commit dependency tracking, a rewritten crash-safe logical log, low-watermark garbage collection, savepoints, hardened conflict detection and lock-free rowid allocation, verified with Antithesis, Hermitage and Elle. The release also adds experimental Tantivy-based full-text search stored inside the SQLite B-tree, and optimizer upgrades: hash joins with bloom filters, outer joins and disk spilling, semi/anti-join decorrelation, multi-index OR scans and a reworked cost model. Rounding it out are STRICT tables with user-defined types via CREATE TYPE, and stable change data capture with a v2 transaction-grouped record format.

  • Anatomy of a (Postgres) search engine

    PlanetScale mediumAdept

    Inverted indexes power full-text search by mapping each term to a sorted, compressed postings list of document IDs, with optional positional data for phrase/span queries and frequency statistics for BM25 scoring. Postings can be delta-encoded or stored as bitmaps for fast SIMD intersection, and block-level statistics let top-k queries skip whole blocks. Indexes are built as immutable segments plus a mutable segment, with deletes handled by tombstones and periodic merges that trade heavy I/O against per-query overhead. Inside Postgres, such an index must map to ctids, be WAL-logged, reuse freed pages, run merges in background workers, and cooperate with VACUUM.

  • Comparing Native Postgres, ElasticSearch, and pg_search for Full-Text Search

    Neon mediumAdept

    Native Postgres full-text search (tsvector/tsquery with GIN indexes) breaks down at scale because ranking by ts_rank must score every matching row and lacks BM25, fuzzy matching and per-field relevance. ElasticSearch fixes search quality and speed but adds a second source of truth, a sync pipeline, eventual consistency and heavy cluster operations. pg_search, a Rust extension built on Tantivy, embeds a BM25 inverted index inside Postgres with transactional updates, fuzzy and phrase queries, snippets and aggregations. On a 10-million-row benchmark it beat native FTS by 20-1000x (e.g. top-N ranked results in 81ms vs 38.8s), and it is pitched for datasets that fit on a single Postgres instance.

  • Postgres Full Text Search vs the rest

    Supabase mediumAdept

    Postgres built-in full text search, using a generated tsvector column with a GIN index and websearch_to_tsquery, performs close to dedicated engines like Typesense, MeiliSearch, OpenSearch and SQLite FTS5 in default configurations on a small movie dataset. Most queries return in a few milliseconds on Postgres. In-memory SQLite was fastest. Only Typesense and MeiliSearch handled misspellings such as "suprman". For basic search needs, Postgres FTS is good enough and adds no new systems to the stack, while dedicated engines offer typo tolerance, prefix search and richer relevancy tuning.

  • Introducing Real-Time Data with Materialized Views in Turso

    Turso mediumAdept

    Turso adds experimental Live Materialized Views to its SQLite-compatible database, using Incremental View Maintenance based on the DBSP framework so views update in time proportional to the size of changes rather than the base tables. SQL queries compile into a DAG of DBSP operators (filter, projection, aggregate, join, merge) through which inserts, updates and deletes flow as deltas applied to the view. Because maintenance is cheap, views carry the same transactional isolation as the rest of the database and reflect uncommitted changes within a transaction and revert on rollback. Recursive CTEs (delay operator) aren't supported yet, and the on-disk format is unstable and not production-ready.

The quest for software engineering knowledge.

Look:
Layout: