How does "find similar" work without reading every row?
Vectors, a distance, and an index that trades a little accuracy for a lot of speed. Then one search, end to end.
The vectors come from an embedding model. The index decides how fast and how accurately you can search them. The source data and its rules live somewhere you already trust.
The same layers as a still diagram, with every part named:
From question to answer
| Place | What it holds | What to watch |
|---|---|---|
| The vectors | dimensions × 4 bytes each, as 32-bit floats: 384 dimensions is 1,536 bytes | Notebook 8: 1,641 bytes per row in the table, with its text and row header. |
| An HNSW index | a copy of every vector plus links to about 2 × m neighbours | Notebook 8: 2,048 bytes per vector at m = 16. Table plus index: 3,689 bytes, 2.4 times the raw floats. Fast only while it fits in memory. |
| An IVF index (ivfflat) | vectors grouped around centroids learned from the data | Build it after the data is loaded. lists and probes trade speed and recall. Recall drops if new data drifts from the centroids. |
| Quantized vectors | halfvec (2 bytes a dimension), or one bit a dimension with binary_quantize. Some dedicated stores also offer int8 | 2 to 32 times smaller. Re-rank the top results with the full vectors to win back recall. |
| Metadata for filters | tenant, permissions, dates | Filtering after the index can return too few rows. Notebook 8: 1.3 rows out of 10. |
100,000 memories for 100 tenants, as in Notebook 8. Step through a search, then tick the box to filter by tenant.
About 95% in Notebook 8, with ef_search at 40. Approximate means it usually finds them, not always. Raising ef_search to 160 found all of them for a little more time.
How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.