pgvector
pgvector is an open-source PostgreSQL extension that adds vector similarity search capabilities to your existing Postgres database. It lets you store embeddings alongside relational data and run similarity queries using familiar SQL, eliminating the need for a separate vector database in many use cases.
On this page
What Is pgvector?
pgvector, created by Andrew Kane and first released in 2021, solves an elegant problem: if your application already uses PostgreSQL, why deploy a separate vector database just for embeddings? pgvector adds a new "vector" data type to Postgres and provides operators for cosine distance, inner product, and Euclidean distance. You can store embeddings in the same table as your business data and query them with standard SQL, joining vector search results with relational data in a single query.
The extension supports two indexing strategies. IVFFlat (Inverted File with Flat compression) partitions vectors into clusters and searches only the most relevant clusters at query time. HNSW (Hierarchical Navigable Small World) builds a multi-layer graph for faster approximate nearest neighbor search. HNSW generally delivers better recall and query performance, while IVFFlat has faster index build times. For small datasets (under 100,000 vectors), sequential scan without an index is often fast enough.
pgvector's killer advantage is operational simplicity. Your team already knows SQL, already has Postgres backups, monitoring, and deployment pipelines, and already understands your relational schema. Adding vector search is a matter of installing the extension and creating an index. There is no new service to deploy, no new SDK to learn, and no data synchronization between a relational database and a vector database. For startups and small teams, this simplicity translates directly to faster development and lower operational burden.
The tradeoff is performance at extreme scale. Purpose-built vector databases like Pinecone, Qdrant, and Weaviate are optimized for billions of vectors with sub-50ms latency. pgvector performs well up to tens of millions of vectors but may require careful tuning (index parameters, maintenance, connection pooling) beyond that. Managed Postgres services like Supabase, Neon, and AWS RDS now include pgvector by default, making deployment even simpler.
Hybrid search (combining vector similarity with keyword matching) is possible in pgvector by using the tsvector full-text search capabilities already built into PostgreSQL alongside pgvector's similarity operators. This native combination of full-text and vector search in SQL is a unique strength that purpose-built vector databases achieve through separate hybrid search features.
Real-World Use Cases
Startup RAG application with unified data layer
A seed-stage SaaS startup builds their RAG chatbot using pgvector on Supabase. User data, conversation history, and document embeddings all live in the same Postgres database. The team of three engineers avoids the operational complexity of a separate vector database, shipping their MVP in 4 weeks instead of 8.
E-commerce product search with relational filtering
An e-commerce platform stores product embeddings alongside inventory, pricing, and category data in Postgres with pgvector. A single SQL query finds semantically similar products that are in stock, within the customer's price range, and in a specific category. No data synchronization between systems is required.
Internal document search for small to mid-size corpus
A company with 500,000 internal documents indexes them in pgvector within their existing Postgres deployment. Employees search using natural language, and the query joins vector similarity results with document metadata (author, department, access level) in a single SQL statement. The project required zero new infrastructure.
Common Misconceptions
pgvector cannot handle production workloads.
pgvector handles millions of vectors in production today across thousands of applications. With HNSW indexing and proper tuning, it delivers query latency under 100ms for datasets up to tens of millions of vectors. It becomes less suitable at the billion-vector scale where purpose-built databases excel.
pgvector is a toy compared to dedicated vector databases.
pgvector's performance has improved significantly with each release. For most applications (under 10 million vectors), it matches the latency and recall of dedicated solutions. Its advantage of unified relational and vector data, combined with the maturity of the PostgreSQL ecosystem, makes it a serious production choice.
You should always use a dedicated vector database.
Adding a dedicated vector database introduces operational complexity: another service to deploy, monitor, back up, and keep in sync with your primary data store. For applications with moderate vector search needs, pgvector eliminates this complexity entirely. Start with pgvector and migrate to a dedicated solution only when you outgrow it.
Why pgvector Matters for Your Business
pgvector matters because it democratizes vector search by bringing it into the most widely used relational database in the world. Teams do not need specialized vector database expertise, new infrastructure, or complex data synchronization pipelines. They add an extension to their existing Postgres database and start building. This dramatically lowers the barrier to adopting AI-powered search, recommendations, and RAG in production applications.
How Salt Technologies AI Uses pgvector
Salt Technologies AI recommends pgvector as the starting point for clients who already run PostgreSQL and have datasets under 10 million vectors. It is our default recommendation for AI Proof of Concept projects because it eliminates infrastructure complexity and accelerates time to first demo. For clients on Supabase or Neon, pgvector is already available with zero setup. We migrate clients to dedicated vector databases (Pinecone, Qdrant) only when their scale or latency requirements demand it.
Further Reading
- Vector Database Performance Benchmark 2026
Salt Technologies AI Datasets
- AI Development Cost Benchmark 2026
Salt Technologies AI Datasets
- pgvector GitHub Repository
pgvector
Related Terms
Vector Database
A vector database is a specialized data store designed to index, store, and query high-dimensional vector embeddings at scale. Unlike traditional databases that search by exact keyword matches, vector databases perform similarity search to find the most semantically relevant results. They are the critical infrastructure component in RAG systems, semantic search engines, and recommendation systems.
Embeddings
Embeddings are numerical vector representations of text, images, or other data that capture semantic meaning in a high-dimensional space. Similar concepts produce similar vectors, enabling machines to measure meaning-based similarity between documents, sentences, or words. Embeddings are the mathematical backbone of semantic search, RAG systems, recommendation engines, and clustering applications.
Retrieval-Augmented Generation (RAG)
Retrieval-Augmented Generation (RAG) is an architecture pattern that enhances LLM responses by retrieving relevant information from external knowledge sources before generating an answer. Instead of relying solely on the model's training data, RAG systems search vector databases, document stores, or APIs to inject fresh, factual context into each prompt. This dramatically reduces hallucinations and enables LLMs to answer questions about private, proprietary, or real-time data.
Semantic Search
Semantic search uses vector embeddings to find documents based on meaning rather than keyword matching. It converts queries and documents into high-dimensional vectors, then finds the closest matches using distance metrics like cosine similarity. This approach understands synonyms, paraphrases, and conceptual relationships that keyword search completely misses.
Pinecone
Pinecone is a fully managed, cloud-native vector database designed for high-performance similarity search at scale. It stores, indexes, and queries vector embeddings with low latency, making it the most widely adopted managed vector database for production RAG and semantic search applications.
Weaviate
Weaviate is an open-source, AI-native vector database that combines vector search with structured filtering, keyword search, and built-in vectorization modules. It offers both self-hosted and managed cloud deployment, making it a flexible choice for teams that need full control over their vector infrastructure.