Quantization & Sparse Vectors
pgvector supports four vector representations so you can balance memory footprint, dimensionality limits, and recall:
| Data Type | Element Type | Max Indexed Dimensions | Storage Size |
|---|---|---|---|
vector(n) |
32-bit float (float32) |
2,000 | bytes |
halfvec(n) |
16-bit float (float16) |
4,000 | bytes |
bit(n) |
1-bit binary (0 / 1) |
64,000 | bytes |
sparsevec(n) |
Non-zero index:float32 pairs |
1,000 non-zero elements (up to 1,000,000 dims) | bytes |
vchordIn addition to pgvector’s built-in quantization types, vchord provides rabitq8 (8-bit) and rabitq4 (4-bit) quantized vector types and supports indexing up to 60,000 dimensions in vchordrq. See vchord Quantization Types.
Half-Precision Vectors (halfvec)
Use the halfvec type (pgvector 0.7.0+) to store 16-bit floating-point vectors, cutting table and index footprint in half compared to vector:
Half-Precision Expression Indexing (Scalar Quantization)
If you want to keep full-precision vector values in the table (or index vectors between 2,001 and 4,000 dimensions, such as OpenAI text-embedding-3-large at 3,072 dimensions), build an expression index casting vector to halfvec:
Binary Vectors (bit) & Binary Quantization
Use PostgreSQL’s built-in bit(n) type with pgvector’s Hamming (<~>) and Jaccard (<%>) operators to store and index binary vectors up to 64,000 bits:
Binary Quantization with Full-Precision Re-Ranking
Use binary_quantize(vector) to compress 32-bit floats to 1 bit per dimension (1 if , 0 otherwise) in an expression index, then re-rank the top candidates using the exact vector column:
Sparse Vectors (sparsevec)
Use sparsevec (pgvector 0.7.0+) to store vectors where most dimensions are zero (such as SPLADE, BGE-M3 sparse outputs, or BM25 term vectors generated by pg_bestmatch).
Sparse Literal Format
Format: '{index1:value1,index2:value2}/dimensions', where indices are 1-based:
Matryoshka Sub-Vector Indexing (subvector)
For models trained with Matryoshka Representation Learning (MRL), you can index only the leading dimensions with subvector(vector, start, count) and re-rank on the full vector: