sqlite-vec on 200,000 Vectors: 119 ms Warm, 2.78 s Cold
sqlite-vec gets recommended for every small RAG project, then slows down at a size nobody warned you about.
📜 Table of Contents
📖 Keep reading
sqlite-vec is the smallest way to get vector search into an app: one extension, no server, one file. On a 2 vCPU, 1.6 GiB VM it inserts 200,000 384-dimension vectors in 8.4 seconds. The same 200,000-vector table answers a top-5 query in 238 ms once the file is in page cache, and takes 2.78 seconds when it is not. That gap, not the row count, is what decides whether you can ship it.
We measured four table sizes on the same machine, with the same query set, and re-ran each size cold and warm. Below are the numbers, the reason for the cliff, and the point where you should stop and move to an HNSW index.
Test setup
| Item | Value |
|---|---|
| CPU | 2 vCPU, Intel Xeon Platinum, shared |
| Memory | 1.67 GiB total, 503 MiB available, 496 MiB in page cache |
| Disk | cloud block volume, 178 MB/s sequential read, measured with dd iflag=direct |
| SQLite | 3.42.0 |
| sqlite-vec | v0.1.9 |
| Vectors | 384 dimensions, float32, L2-normalised |
| Query | k = 5, cosine distance via MATCH and ORDER BY distance |
One honesty note before the tables: the vectors are synthetic, drawn from a fixed-seed normal distribution. sqlite-vec's vec0 table has no approximate index in 0.1.x, so a query is a full scan of every row. The cost is arithmetic over 384 floats per row and does not depend on what the values mean. That makes synthetic vectors valid for latency and disk-size measurement, which is what this article is about. It would not be valid for recall comparisons between embedding models, and none are made here.
Writes are not the problem
| Rows | Insert time | Vectors/sec | File size | Bytes per vector |
|---|---|---|---|---|
| 25,000 | 1.4 s | 17,930 | 38.1 MiB | 1,597 |
| 50,000 | 2.5 s | 20,139 | 74.7 MiB | 1,567 |
| 100,000 | 4.4 s | 22,705 | 149.4 MiB | 1,566 |
| 200,000 | 8.4 s | 23,851 | 298.8 MiB | 1,566 |
Throughput settles around 23,000 vectors per second once the table is past the first few thousand rows, batched at 2,000 rows per transaction. A 1,536-byte float32 vector costs about 30 bytes of overhead, so sizing is predictable: 1 million 384-dimension vectors is a 1.49 GiB file. Ingest on this box is not a bottleneck at all. If your pipeline is slow, the embedding call is the reason, not the write.
One microsecond per vector, every time
| Rows | p50 warm | p95 warm | Microseconds per vector |
|---|---|---|---|
| 25,000 | 29.1 ms | 85.9 ms | 1.16 |
| 50,000 | 58.5 ms | 69.9 ms | 1.17 |
| 100,000 | 119.0 ms | 132.7 ms | 1.19 |
| 200,000 | 237.7 ms | 269.8 ms | 1.19 |
The cost per vector sits at 1.16 to 1.19 microseconds across an 8x range of table sizes. That is the signature of a linear scan, and it is also a reliable planning number: on a 2 vCPU machine a warm query costs roughly 1.2 microseconds times the number of rows. 300 milliseconds at 250,000 rows, 1.2 seconds at 1 million.
k barely matters. On the 100,000-row table, median latency was 118.0 ms at k = 1, 119.0 ms at k = 5, 116.7 ms at k = 20 and 120.7 ms at k = 50, a 3.4 percent spread. The scan dominates; the top-k sort is noise until k gets large. Raising k from 5 to 50 costs less than measuring it twice would.
The real cliff is page cache
Run the same 50,000-row table twice in a row and you get two different products:
| Rows | File size | First query after writing the file | Subsequent queries, p50 | Cold/warm ratio |
|---|---|---|---|---|
| 50,000 | 74.7 MiB | 1,400.6 ms | 58.5 ms | 24x |
| 200,000 | 298.8 MiB | 2,780.0 ms | 237.7 ms | 11.7x |
On the 200,000-row table we warmed the cache with five throwaway queries before measuring. It still came back at 2,780 ms, because 299 MiB does not stay resident next to the OS, the Python interpreter and whatever else runs on a 1.6 GiB box. The volume reads at 178 MB/s, so a full scan of 299 MiB from disk costs about 1.7 seconds of I/O plus the arithmetic, and that is what the 2.78 s is made of. A second run, with the file freshly cached, dropped to 238 ms.
This is the failure mode that never shows up in a benchmark that loads data and queries in one process. It shows up in three places instead:
- CLI tools and one-shot scripts. Every new process starts with a cold cache when memory is tight, so the user sees the 2.8-second number, not the 238 ms one.
- Restarts. The first requests after a service restart on a small VM are an order of magnitude slower.
- Memory pressure. Anything else on the box that grows, a web server or an embedding worker, evicts the vector file, and latency flips between the two modes without warning.
How to predict it on your own machine
Compare the index file to available page cache, not to total RAM:
# 1. what the table will cost on disk
python3 -c "print(round(1_000_000*1566/1048576), 'MiB for 1M x 384')"
# 2. what is actually available for caching right now
grep -E "MemAvailable|^Cached" /proc/meminfo
# 3. what the query really does
sqlite3 your.db "EXPLAIN QUERY PLAN
SELECT rowid FROM vec_items WHERE embedding MATCH zeroblob(1536) AND k = 5;"
If the file is under half of MemAvailable, expect the warm number. If it is larger, expect the cold number on every query once the cache turns over, because a full scan touches every page of the table. There is no partial-cache benefit to hope for.
Where to stop
| Table size | Warm query on 2 vCPU | Verdict |
|---|---|---|
| up to 50,000 | 29 to 59 ms | Comfortable. Any app, any pattern, including cold starts. |
| 50,000 to 200,000 | 59 to 238 ms | Fine for a chatbot answering one question at a time. Plan for cold queries. |
| 200,000 to 1,000,000 | 238 ms to 1.2 s | Only with the file pinned in memory. On 1 GiB this is where you move to HNSW. |
| above 1,000,000 | over 1.2 s warm, about 9 s cold | Wrong tool. Use Qdrant, pgvector with HNSW, or faiss. |
The upgrade decision is not about how many vectors SQLite can hold, because it will hold millions. It is about whether the working set fits in cache. On a 1 GB VPS with a 120 MB app on top, sqlite-vec stays interactive to roughly 200,000 vectors. Past that, an HNSW index answering in 2 to 5 ms stops being an optimisation and becomes the difference between a product and a demo.
The other direction is worth saying too. Below 50,000 vectors, adding Qdrant means running a second service, a second backup, a second thing to monitor, to save 30 milliseconds. For a side project, a CLI, or a single-tenant app, one file and no daemon is the right call.
Minimal working setup
pip install sqlite-vec numpy
import sqlite3, sqlite_vec, numpy as np
db = sqlite3.connect("vectors.db")
db.enable_load_extension(True)
sqlite_vec.load(db)
db.enable_load_extension(False)
db.execute("CREATE VIRTUAL TABLE IF NOT EXISTS vec_items USING vec0(embedding float[384])")
# 2,000 rows per commit measured fastest here
rows = [(i, vec.astype(np.float32).tobytes()) for i, vec in enumerate(vectors, 1)]
db.executemany("INSERT INTO vec_items(rowid, embedding) VALUES (?,?)", rows)
db.commit()
q = query_vec.astype(np.float32).tobytes()
hits = db.execute(
"SELECT rowid, distance FROM vec_items WHERE embedding MATCH ? AND k = 5 ORDER BY distance",
(q,)).fetchall()
Two details that cost people an afternoon: the column must be declared as float[384] with the dimension in brackets, and the query vector goes in as raw float32 bytes, not a JSON string and not a Python list.
FAQ
Does sqlite-vec use an approximate index? Not in 0.1.9. vec0 scans all rows and keeps the best k, which is why latency is exactly linear in row count. Until ANN support ships, plan on the numbers above.
Is 384 dimensions the right size to test with? It is the most common embedding width, used by all-MiniLM-L6-v2, bge-small and e5-small. A 768-dimension model doubles both file size and scan time, so about 2.4 microseconds per vector, or 240 ms at 100,000 rows.
How many queries per second is that? At 238 ms per query on one core, about 4 QPS single-threaded. Two cores in parallel get you near 8 before disk contention. Enough for a chat app with one user at a time, not enough for a public search box.
Can I filter on metadata in the same query? Yes, with auxiliary columns declared in the table definition, and the filter runs during the scan. It does not make the scan cheaper, so add filter columns to cut the result count, not the latency.
Related
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.