Wink Pings

0.037 ms Is Fast, but the 7 MB Index Is Fatter Than the Source Text

A real-world test of Tantivy on 1,511 notes: queries are about 5× faster than FTS5, but the index is 2.5× larger, and the default OR query lets typos through. On small datasets, FTS5 may still be the better deal.

0.037 ms. That is the median X user ReignSwords got when searching 1,511 of his own documents with Tantivy. The data was 2.9 MB of real post logs and research notes, not demo data.

test screenshot

He recorded the full numbers:

  • Indexing: 0.36 seconds
  • Query median: 0.037 ms; p95: 0.089 ms
  • Same documents with SQLite FTS5: median 0.172 ms
  • Pure Python scan: 21 ms

Converted, Tantivy is about 5× faster than FTS5 and about 570× faster than scanning. Tantivy is a search library written in Rust, with BM25 ranking, similar to Lucene. You can use it with pip install tantivy; no Rust toolchain and no service to maintain. For readers who do not write code, think of it as a local full-text search library; SQLite FTS5 is SQLite’s built-in full-text search module.

The problems then appear. The index is 7.3 MB versus 2.9 MB of source text, a 2.5× expansion. The default query is OR, not AND. Entering the misspelled “codng agent” still returns 10 hits, all matching “agent.” The system does not warn that half of the query is invalid. It also does not stem by default: “bookmarks” returns 0 results in notes full of “bookmark.”

The test method was also disclosed: 1,511 documents came from post logs and research notes, split by paragraph, each over 80 characters and up to 4,000 characters; 8 queries, each run 50 times, median taken. FTS5 used quoted AND conditions, stricter than Tantivy’s default OR, so that part of the gap must be counted. The query “elasticsearch” returned 0 results on both sides. The corpus was mostly English with some Chinese; neither tokenizer received special handling.

The conclusion is straightforward: if the corpus fits in SQLite, FTS5’s 0.17 ms is already faster than users can perceive, and it is right there in the existing database. Tantivy is better suited to 100k+ documents, or to embedding search in a Rust binary. Speed was never the bottleneck; query syntax is.

Some comments said FTS5 is good enough below 10k documents, and others complained about the 7 MB index. ReignSwords replied that at the 1,511-document scale, FTS5’s 2.2 MB index is the better deal.

Source: https://x.com/ReignSwords/status/2129028772938531297

Tantivy PyPI: https://pypi.org/project/tantivy/

发布时间: 2026-12-05 11:26