In this article
An index over a halfvec cast can preserve original vectors for rescoring, unlike replacing the stored column.
A halfvec expression index can use a reduced-precision search representation without replacing the original vectors stored in the table. Keep that distinction explicit when evaluating index size and final ranking, because storing half precision and indexing a cast are different choices.
Choose what is being reduced
The pgvector README documents both a halfvec column and an expression index over a cast from an existing embedding. In the latter design, original values remain available for another scoring stage. Replacing the table column changes what data survives. Decide which operation is intended before comparing footprints, and retain the original model revision and vector dimensionality in either case.
Match the indexed expression
PostgreSQL uses the expression declared by the index, not an informal intention to search at half precision. Its expression-index documentation explains this distinction. An illustrative index for three-dimensional data might use embedding::halfvec(3) with the corresponding operator class. The search must use the matching expression and distance operation. This is an example of structure, not a recommended embedding dimensionality for a real retrieval corpus.
Inspect the type and operator contract
The extension SQL definitions expose the halfvec functions, casts and operators. Preserve the selected distance rather than replacing cosine with another metric while also changing precision. An experiment varying both would not identify the source of rank changes. Check the installed extension version and explain the actual plan; a valid query can still use another path when its expression or cost conditions differ.
Separate shortlist and final order
Consider a diagnostic corpus containing near-duplicate passages and a small set of labeled queries. Use the half-precision representation to select a candidate pool, then compute the intended final distance with original vectors. Save both orderings and candidate IDs. A relevant document missing from the shortlist cannot be recovered through precise rescoring. Conversely, a changed shortlist order may be harmless if the final useful evidence remains present.
| Stage | Representation to record |
|---|---|
| Stored source | Original vector |
| Candidate index | Explicit halfvec expression |
| Final scoring | Declared original-vector metric |
Measure more than index files
Record index footprint, original table footprint, working allocations and query behavior separately. A smaller index does not remove the original data or make every query faster. Reranking must read the original vectors, and workload locality can change its cost. Evaluate candidate recall and final relevance together with elapsed time. Do not copy another corpus’s reported precision loss as a guarantee for your own near-neighbor distribution.
Preserve a migration comparison
Retain an exact original-vector baseline on a manageable fixture. Change the indexed representation first while keeping input queries, filters and final scoring fixed. If the intended design also changes stored precision, make that another experiment with its own rollback data. The result should describe which representation was reduced and which information remains recoverable, rather than broadly declaring that the database now uses half the memory.
Related reading: PostgreSQL and pgvector for RAG on an existing server; Embedding dimensions: calculating index memory.