Vector Search Is Not a Purchase, It Is Ten Lines of SQL
6,152 bytes: the space one 1,536-dimension embedding takes in a Postgres table, arithmetic the pgvector README states plainly as 4 bytes per dimension plus 8 of header. A catalog of 400,000 products carries about 2.5 GB of embeddings in total. Hold that number against the pricing conversation a search box tends to drag its owner into, and the argument of this tutorial is half made: the vectors that answer a human-scale question do not require an infrastructure decision.
The claim worth testing: at the scale most products actually search, a vector column in the Postgres database you already run, or even a cosine sort over a file, answers correctly, and the dedicated vector database is a decision for later, when writes, latency, or scale force it. The three moves below go from least to most infrastructure, and the right one for you is determined by your workload, not by a category page.
Ten lines of SQL, zero infrastructure
Start where a demo starts, in a file. DuckDB carries a fixed-size ARRAY type and a cosine function in the core, and a column of floats sorted by similarity is the entire mechanism of "semantic search":
CREATE TABLE items (id INTEGER, name TEXT, embedding FLOAT[3]);
INSERT INTO items VALUES (1, 'ski boots, size 28', [0.9, 0.1, 0.0]::FLOAT[3]);
INSERT INTO items VALUES (2, 'beach towel', [0.0, 0.9, 0.1]::FLOAT[3]);
SELECT id, name,
array_cosine_similarity(embedding, [0.8, 0.6, 0.0]::FLOAT[3]) AS sim
FROM items
ORDER BY sim DESC
LIMIT 5;
In the 3-dimensional toy every step is visible: one scan, one similarity per row, a sort, a limit. Swap the toy for a real column of 1,536-dimension embeddings from the model of your choice and the SQL does not change, only the size behind it. This is the honest shape of brute force: the whole table is read on every query. It costs no deployment and no new server to justify, whether the search runs on demand or in batch. The per-query cost grows linearly with the catalog, which is the whole tradeoff in one clause, and it stays affordable far past the size where an Excel VLOOKUP died. Nothing sits waiting to be rebuilt, either: there is no index in this path, so a catalog re-embedded in the morning is visible to the afternoon's query.
Where "affordable" ends is a question your own traffic answers, not ours, and we are deliberately not printing a benchmark in its place. What arithmetic can state is the memory shape: a few hundred thousand vectors at 1,536 dimensions is a few gigabytes, comfortably inside one machine's RAM. At tens of millions, the scan starts reading cold pages and the linear clause begins to hurt.
pgvector puts an index in the database you already run
The graduation from a sort to an index does not require a new service. It requires one extension and one index in Postgres:
CREATE EXTENSION vector;
CREATE TABLE items (
id BIGSERIAL PRIMARY KEY,
name TEXT,
embedding vector(1536)
);
CREATE INDEX ON items
USING hnsw (embedding vector_cosine_ops);
-- $1 is your query embedding, same dimensions as the column
SELECT id, name
FROM items
ORDER BY embedding <=> $1::vector
LIMIT 10;
Two changes matter more than the syntax. First, without the index pgvector runs exact search, full scan, perfect recall; the HNSW index trades a little recall for speed, and the README is explicit that results change after approximate indexing, so a recall check belongs in the same golden-question file a RAG system keeps. Second, and this is the reason the vectors belong in the relational database at all: the filters live beside the vectors. "In stock, this brand, within 40 miles, closest to the description typed" is one query in one database.
Keeping vectors in a separate store is the dead end we would undo first. The early arrangement looks clean, a specialist engine for exotic math, and then every result page pays the app-code join: pull candidates from the vector service, fetch their rows from the database, throw away whatever fell out of the WHERE clause. Each request buys the gap between two systems. Merging the columns into one table deletes that join, deletes the extra round trips, and deletes an entire credential, quota, and version of a service nobody needed.
The dimensions deserve their honesty note too. pgvector's vector type indexes up to 2,000 dimensions, its halfvec alternative up to 4,000, so a 1,536-dimension model fits comfortably while some of the widest embedding models shipped in 2025 do not, and choosing the column type is part of choosing the model.
The graduation exam: before a new server, answer three questions
The dedicated vector databases earn their keep in real workloads, so the question is which workload you have. Three cover every case you are likely to meet.
Do you sustain writes faster than an index can absorb them? An HNSW build in Postgres is slower and hungrier than its queries, and embedding backfills that trigger constantly will show it. A service built around continuous reindexing turns that pain into a product feature.
Is your latency target one a full scan cannot honor? Under concurrent load, per-query cost multiplied by simultaneous users is the bill, and at some traffic the index inside Postgres stops carrying it. That clause, concurrency, is where a managed service's real value sits.
Have you outgrown one machine? Tens or hundreds of millions of vectors, sharding, replicas: at that point the managed stores, of which the Postgres-compatible and standalone families both have mature options, stop being a category and start being a procurement.
If the answer to all three is no, the graduation is not due. If one answer is yes, graduate on it, and write down which one triggered the move, because that constraint also decides which store fits.
What this tutorial deliberately does not settle
No benchmark for your traffic lives in this post, on purpose: recall targets and query rates are yours, ours are different. The arithmetic gives the sizes, the README gives the index behavior, and neither of us substitutes for a measurement on your data. Recall is the silent quality here, since an approximate index that misses the right product looks identical to the user except where it hurts.
And the ten-lines claim has an honest edge: it holds while one machine holds your vectors comfortably. That ceiling is high, much higher than the pricing conversation assumes, but it is a ceiling, and it is the ceiling the exam above is built to detect.
The decision in one line: put the embeddings beside the rows they describe, in the database already running, sorted or indexed as your traffic demands, and keep the graduation exam on the wall where those three questions live. Most search boxes finish the quarter on the table they started on.
AngoraTek builds search and retrieval on the smallest stack that holds, Postgres included, and moves teams only when a constraint forces the move. Show us your search box if the pricing conversation has come before the workload.Thanks for reading this far. If this sounds like the problem you're wrestling with, tell us about it. The team reads every message.
Start a conversation