---
title: "pgvector: Fewer dimensions are better"
description: "Lower-dimensional embedding models can match or beat OpenAI's 1536-dimension text-embedding-ada-002 on the MTEB leaderboard while making pgvector queries much cheaper, since fewer dimensions mean fewer distance computations and smaller indexes that fit in RAM."
url: "https://swe.quest/articles/pgvector-fewer-dimensions-are-better-23087227ac0db157"
canonical: "https://supabase.com/blog/fewer-dimensions-are-better-pgvector"
source: "Supabase"
published: "2023-08-03"
difficulty: "medium"
kind: "Research"
reading_minutes: 6
tags: ["vector-search","postgres","performance","rag"]
---

# pgvector: Fewer dimensions are better

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2023-08-03, 6 min read, Research. Original: [https://supabase.com/blog/fewer-dimensions-are-better-pgvector](https://supabase.com/blog/fewer-dimensions-are-better-pgvector)

## Summary

Lower-dimensional embedding models can match or beat OpenAI's 1536-dimension text-embedding-ada-002 on the MTEB leaderboard while making pgvector queries much cheaper, since fewer dimensions mean fewer distance computations and smaller indexes that fit in RAM. In a benchmark on a 2vCPU/8GB Postgres 15 instance with 224k Wikipedia embeddings and an IVF index (lists=1000), 384-dimension all-MiniLM-L6-v2 delivered 78% more queries per second than ada-002 at accuracy@10 of 0.99 and used about 4GB of RAM instead of 7.5GB. gte-small, also 384 dimensions, reached the same accuracy with probes=10 and more than tripled throughput over MiniLM. The recommendation is to choose models by MTEB score, model size, sequence length, dimensions and language support, and to avoid PCA or t-SNE for shrinking vectors because they lose semantic structure and drift as the data changes.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)
- [RAG & retrieval](https://swe.quest/tags/rag.md) (AI & ML)

## Prerequisites

- vector embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- PostgreSQL indexes ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- approximate nearest neighbor search ([easy posts on Search](https://swe.quest/tags/search.md?difficulty=easy))

## Keywords

pgvector, text-embedding-ada-002, gte-small, all-MiniLM-L6-v2, MTEB, IVF index, Supabase

## Related posts

- [Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval](https://swe.quest/articles/matryoshka-embeddings-faster-openai-vector-search-using-adaptive-retrieval-739d1a8595798695.md): Supabase · 2024-02-13 · Medium · 17 min read · Vector search, PostgreSQL, RAG & retrieval, Performance engineering
  OpenAI's text-embedding-3 models are trained with Matryoshka Representation Learning, so an embedding can be shortened by truncating trailing dimensions and renormalizing, which reproduces the API's \`dimensions\` output.
- [pgvector 0.4.0 performance](https://swe.quest/articles/pgvector-0-4-0-performance-559fc540f926a562.md): Supabase · 2023-07-13 · Medium · 8 min read · Vector search, PostgreSQL, Performance engineering, Inference & serving
  With tuned settings, pgvector 0.4.0's IVFFlat index handles 1M OpenAI embeddings (1536 dimensions, dbpedia dataset) at about 1800 QPS with 0.91 accuracy@10 on a 64-core, 256 GB instance, or about 670 QPS at 0.98 accuracy.
- [20x faster than pgvector: introducing pg\_embedding extension for vector search in Postgres and LangChain](https://swe.quest/articles/20x-faster-than-pgvector-introducing-pg-embedding-extension-for-vector-search-058737fc9388f495.md): Neon · 2023-07-11 · Medium · 7 min read · Vector search, PostgreSQL, Performance engineering
  pg\_embedding brought HNSW graph-based approximate nearest neighbor indexing to Postgres.
- [Don’t use vector. Use halvec instead and save 50% of your storage cost](https://swe.quest/articles/don-t-use-vector-use-halvec-instead-and-save-50-of-your-storage-cost-bd6cf6e833bfde8c.md): Neon · 2024-07-31 · Medium · 4 min read · Vector search, PostgreSQL, Performance engineering, RAG & retrieval
  pgvector 0.7's half-precision halfvec type stores embedding components as 16-bit floats instead of 32-bit, cutting table and HNSW index storage nearly in half.
- [pgvector v0.5.0: Faster semantic search with HNSW indexes](https://swe.quest/articles/pgvector-v0-5-0-faster-semantic-search-with-hnsw-indexes-d1e5c38ac44f551e.md): Supabase · 2023-09-06 · Medium · 6 min read · Vector search, PostgreSQL, Performance engineering, Algorithms
  pgvector v0.5.0 adds HNSW indexes, which combine skip-list-style layering with navigable small world proximity graphs to do approximate nearest-neighbor search over embeddings.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
