Database / pgvector basics Interview Questions
What is the pgvector maximum supported dimensions limit and how do you handle high-dimensional vectors?
pgvector has dimension limits that vary by data type. These limits are generous for current embedding models but may be a consideration for future or custom embeddings.
| Type | Max dimensions | Notes |
|---|---|---|
| vector(n) | 16,000 | Standard; covers OpenAI (1536/3072), most models |
| halfvec(n) | 16,000 | Half-precision; same dim limit, half storage |
| bit(n) | 64,000 | Binary quantised; very high dimension support |
| sparsevec(n) | 1,000,000 | Sparse vectors; only non-zero values stored |
-- Check current dimension limit at runtime: SELECT current_setting('vector.max_dimensions'); -- If you need > 16,000 dimensions (rare in practice): -- Option 1: Use sparsevec if vector is sparse CREATE TABLE items ( id BIGSERIAL PRIMARY KEY, embedding SPARSEVEC(100000) -- up to 1M dims ); -- Option 2: Dimensionality reduction before storage -- Use PCA or UMAP to reduce from e.g. 65536-dim to 2048-dim -- then store as vector(2048) -- Option 3: Split vector across columns (workaround, ugly) -- Not recommended but possible for extreme edge cases -- Real-world dimension reference: -- text-embedding-3-small: 1,536 dims (well within limit) -- text-embedding-3-large: 3,072 dims (well within limit) -- CLIP image embeddings: 512-768 dims (well within limit) -- Custom deep models: may go up to 4096 dims -- All well within the 16,000 dim limit for vector(n)
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
