Why every software engineer should learn vector databases
Vector databases have moved from ML research teams into everyday backend engineering. This guide explains how embeddings, HNSW and quantization, hybrid search, and metadata filtering actually work—plus when a plain Postgres table with pgvector is all you need.

Table of Contents6 sections
Picture a shopper typing quiet keyboard for late-night coding into an online store. Your best matching product is titled low-profile tactile switches with dampened acoustics. If your backend runs a SQL filter or a standard keyword query, not a single word overlaps. The user sees an empty screen and leaves.
Most software engineers rely on two trusted models for retrieving data. For exact keys or ranges, you reach for a B-tree index in a relational database. For matching words inside text, you reach for an inverted index like BM25 in Postgres or Elasticsearch. Both tools remain essential. Neither grasps what a sentence means when phrasing shifts.
Vector databases close that gap. They have moved out of ML teams into everyday backend work. Product teams ship semantic search and document question answering alongside duplicate detection and image lookup as routine sprint work. You do not need to train neural networks to use one, just as you do not need to code a B-tree page split to run Postgres. You do need a clear model of how vector storage works, what approximate search trades away, and when a dedicated engine is unnecessary.
How meaning turns into numbers
Traditional databases treat text as discrete symbols. To a relational engine, quiet and dampened are unrelated byte sequences. A vector database begins with a different representation called an embedding.
An embedding model turns an input (a paragraph or an image) into a fixed-length list of floating-point numbers. That list is a vector: a point in high-dimensional space. Inputs with similar meaning land near each other; unrelated inputs land far apart. The query quiet keyboard for late-night coding shares zero words with low-profile tactile switches with dampened acoustics, yet a text embedding model places both vectors nearby.
In practice, vectors span hundreds or thousands of dimensions. Sentence-Transformers' open-source all-MiniLM-L6-v2 maps sentences and paragraphs into a 384-dimensional dense vector space. Commercial APIs often go wider. OpenAI's embeddings documentation lists 1,536 default dimensions for text-embedding-3-small and 3,072 for text-embedding-3-large. Extra dimensions encode finer distinctions, though storage and memory scale linearly with length.
Once records become vectors, search becomes geometry. Your backend passes the user's query through the same embedding model, then asks the database for the closest stored vectors. Engines offer three common metrics. Euclidean distance measures straight-line separation. Cosine similarity checks the angle regardless of length, while dot product sums coordinate-wise products.
Those choices are simpler than they look. Many APIs normalize vectors to length 1. OpenAI's docs note that because its embeddings have length 1, cosine similarity can be computed slightly faster with a dot product, and Euclidean distance gives the identical ranking. Checking normalization early prevents silent accuracy loss.
Running memory math early also prevents surprises. Standard embeddings store each coordinate as a 32-bit float (float32), consuming 4 bytes. Storing 1,000,000 items with 1,536-dimensional float32 vectors takes 6,144,000,000 bytes, or roughly 6.14 GB (5.72 GiB) before index overhead. Switching to 384-dimensional all-MiniLM-L6-v2 cuts that footprint to 1.54 GB (1.43 GiB). That quick math explains why stashing vectors in a JSON column works in a prototype and stalls in production.
Why relational and full-text indexes fall short
Backend engineers often ask why a standard database index cannot sort vectors and return the closest matches. B-trees work because numbers and strings follow one linear order: every comparison cuts the remaining space in half. Jump from one dimension to 384 or 1,536 dimensions, and no single sort order keeps neighbors close on disk. Spatial trees like k-d trees degrade toward full scans as dimensionality rises.
Inverted indexes hit a different wall. They map tokens to documents, which makes them hard to beat for an invoice ID or an error string. They miss whenever users describe an idea using words absent from the source text.
Brute-force search compares the query vector against every stored vector and guarantees exact matches. At small scale, brute force works well. Scanning 10,000 vectors of 1,536 dimensions reads roughly 61.4 MB (58.6 MiB) of contiguous floats, which modern CPUs finish fast. Scale to tens of millions of rows under concurrent traffic, though, and linear scans saturate CPU and memory bandwidth immediately.
Vector databases solve this with Approximate Nearest Neighbor (ANN) indexes. Rather than guaranteeing exact matches on every query, an ANN index trades a small slice of accuracy (recall) for much lower latency. Relational queries are deterministic. Vector queries balance recall against latency and RAM.
Two index families handle most workloads. The most common is HNSW (Hierarchical Navigable Small World graphs), introduced by Malkov and Yashunin. Modeled after skip lists, HNSW builds a multi-layer proximity graph. Upper layers hold sparse long-range links for coarse jumps; lower layers hold dense local links for fine search. Descending from the top yields logarithmic complexity scaling with high recall and low latency, though builds take longer and the graph needs substantial RAM.
The second family partitions space into clusters, known as Inverted File (IVF) indexing and popularized by Meta's FAISS library (Johnson, Douze, and Jégou). IVF groups vectors into coarse buckets at build time and searches only the buckets closest to the query. It builds faster and uses less RAM than HNSW, though tuning buckets and probes takes care to protect recall.
When collections outgrow RAM, engines rely on disk-aware graphs and quantization. DiskANN, published by Subramanya and colleagues at NeurIPS 2019, pairs a Vamana graph with compressed vectors in memory and full vectors on SSD. In that paper, DiskANN served 1 billion points on one 16-core machine with 64 GB of RAM and an SSD, sustaining over 5,000 queries per second under 3 ms mean latency and above 95% 1-recall@1. Quantization shrinks vectors directly by storing fewer bits per coordinate. Qdrant's docs explain that scalar quantization maps 32-bit floats to 8-bit integers for a 4x memory cut (turning 6.14 GB into 1.54 GB) with minimal accuracy loss. Binary quantization compresses coordinates to 1 or 2 bits for up to 32x reduction (192 MB at 1 bit for those million vectors), normally paired with rescoring against full vectors on disk. Product quantization reaches up to 64x compression when memory dominates.
Where vector search shows up in production
Because vector stores grew alongside large language models, many developers view them purely as chatbot plumbing. Retrieval-Augmented Generation (RAG) is indeed a flagship pattern. In the 2020 NeurIPS paper introducing the term, Lewis and colleagues paired a sequence-to-sequence model (parametric memory) with a dense vector index of Wikipedia accessed by a neural retriever (non-parametric memory). Instead of retraining an LLM whenever docs change or cramming huge files into prompts, a RAG service pulls only the passages closest in meaning to the question. Answers stay grounded in fresh data with clear source provenance.
Still, RAG is only one piece of real-world vector usage.
Hybrid search often delivers the quickest win for backend teams. Pure vector search struggles with exact strings like an error code or a SKU where literal matching beats broad topic similarity. Pure keyword search has the opposite flaw. Production stacks therefore run both—combining a BM25 keyword query with a dense vector query—and merge the ranked lists. The standard merge method is Reciprocal Rank Fusion (RRF), introduced by Cormack, Clarke, and Büttcher at SIGIR 2009. Because RRF merges lists using only rank positions (with a constant of 60 found near-optimal) rather than raw scores, engineers skip the fragile work of calibrating BM25 scores against cosine distances.
Vector search also simplifies recommendations and duplicate detection. Surfacing related articles or clustering support tickets about the same outage reduces to nearest-neighbor lookups once records are embedded. Multimodal models push this past text. OpenAI's CLIP (Radford et al., 2021) trained on 400 million image-text pairs so images and captions share one embedding space. Store those vectors, and a backend engineer can ship text-to-image search with the same API used for text.
One production hurdle surprises almost every team leaving prototypes behind: metadata filtering. Real queries rarely ask for globally closest vectors. They ask for the closest vectors belonging to a specific tenant and visible to the signed-in user. Mixing strict filters with an ANN graph is tricky.
When an engine runs post-filtering (fetching top vector candidates first and dropping rows failing the SQL WHERE clause afterward), selective filters can starve results. The pgvector docs give a concrete example: because approximate indexes filter after scanning, a condition matching 10% of rows with the default hnsw.ef_search of 40 returns about 4 rows on average. Engines have adapted to close that hole. Starting in version 0.8.0, pgvector added iterative index scans (hnsw.iterative_scan and ivfflat.iterative_scan) that keep exploring until enough matching rows appear. Dedicated engines like Qdrant pair payload indexes with extra graph edges inside HNSW so traversal stays connected under tight filters. Checking how an engine handles filtered ANN queries matters far more in production than unfiltered speed charts.
Dedicated vector databases versus extending Postgres
Once a team adopts vector search, the main decision is whether to extend an existing database or run a dedicated vector engine. The right call depends on scale and operational budget, along with how tightly embeddings tie to transactional state.
Adding pgvector to PostgreSQL is usually the best default if you already run Postgres. You keep ACID transactions and SQL joins inside one system with point-in-time recovery. When a row changes, its embedding updates inside the same transaction, preventing dual-write sync bugs. pgvector supports HNSW and IVFFlat indexes with L2 (<->) and cosine distance (<=>) alongside negative inner product (<#>) operators. Its indexing caps matter upfront: vector columns index up to 2,000 dimensions, half-precision halfvec up to 4,000, and binary bit up to 64,000. Storing 3,072-dimensional vectors from text-embedding-3-large therefore requires casting to halfvec or shortening dimensions before indexing.
Dedicated vector databases—such as Qdrant or Milvus (an Apache 2.0 project under the LF AI & Data Foundation scaling from laptops to distributed clusters) alongside managed Pinecone—earn their keep once vector retrieval becomes a primary workload. Large HNSW graphs compete directly with Postgres's buffer pool for RAM. Crossing tens of millions of vectors or serving heavy filtered reads across shards justifies isolating vector retrieval from OLTP traffic.
Knowing when not to use a vector database matters equally. For a few thousand help articles or 10,000 product rows, an exact Postgres scan without an ANN index runs fast and delivers 100% recall with zero tuning. Even Qdrant exposes a full_scan_threshold_kb setting below which it skips HNSW for an exact scan. Likewise, if users search exact IDs or structured fields, B-trees and inverted indexes beat vector search on cost and accuracy. Spinning up a distributed cluster before outgrowing exact scans or pgvector adds work without payoff.
What software engineers should learn first
You do not need deep ML theory to use vector databases well. Five practical habits cover most choices.
First, treat your embedding model as a strict schema contract. Vectors from different models (or two versions of one model) occupy incompatible spaces. Querying all-MiniLM-L6-v2 records with a text-embedding-3-small vector produces nonsense. Model upgrades require re-embedding every row, so store model name and version beside your data from day one.
Second, focus on chunking and distance metrics. Match your index operator to the model's metric and check normalization. Because an embedding compresses an entire span into one vector, stuffing a long manual into one embedding blurs every topic; splitting text into coherent chunks often improves retrieval more than swapping engines.
Third, learn the core ANN knobs and RAM math. Understand how hnsw.ef_search trades latency for recall, and estimate raw float size plus 4x scalar or 32x binary quantization savings before sizing machines.
Fourth, default to hybrid search and test metadata filters early. Pair BM25 with vector retrieval via RRF whenever users type exact codes beside plain-language queries, and test strict multi-tenant filters on realistic row counts before launch.
Fifth, build a small evaluation set before tuning. A few dozen real queries paired with expected top documents show immediately whether quantization or new chunking rules improved recall or quietly damaged it.
Vector databases now sit beside relational engines and full-text indexes as standard backend tools. Engineers who know how embeddings encode meaning, how approximate indexes trade recall for speed, and when a plain Postgres table suffices will ship calmer search and AI features without carrying unnecessary infrastructure.
References
[1] Yu. A. Malkov and D. A. Yashunin, Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs, arXiv:1603.09320 (IEEE TPAMI 2020): arxiv.org/abs/1603.09320
[2] Jeff Johnson, Matthijs Douze, and Hervé Jégou, Billion-scale similarity search with GPUs (FAISS), arXiv:1702.08734: arxiv.org/abs/1702.08734
[3] Suhas Jayaram Subramanya et al., DiskANN: Fast Accurate Billion-point Nearest Neighbor Search on a Single Node, NeurIPS 2019: proceedings.neurips.cc
[4] Patrick Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, NeurIPS 2020, arXiv:2005.11401: arxiv.org/abs/2005.11401
[5] Gordon V. Cormack, Charles L. A. Clarke, and Stefan Büttcher, Reciprocal Rank Fusion outperforms Condorcet and individual Rank Learning Methods, SIGIR 2009: cormack.uwaterloo.ca
[6] Alec Radford et al., Learning Transferable Visual Models From Natural Language Supervision (CLIP), arXiv:2103.00020: arxiv.org/abs/2103.00020
[7] pgvector Official Repository: github.com/pgvector/pgvector
[8] OpenAI API Docs, Vector embeddings: developers.openai.com/api/docs/guides/embeddings
[9] Sentence-Transformers, all-MiniLM-L6-v2: huggingface.co/sentence-transformers/all-MiniLM-L6-v2
[10] Qdrant Docs, Quantization, Indexing, and Filtering: qdrant.tech/documentation/manage-data/quantization/, qdrant.tech/documentation/manage-data/indexing/, qdrant.tech/documentation/search/filtering/
[11] Milvus Docs, What is Milvus?: milvus.io/docs/overview.md