T
traeai
登录
返回首页
Databricks

What is pgvector?

5.5Score
What is pgvector?
AI 深度提炼
  • 文章未提供pgvector的技术定义、原理或使用场景
  • 正文内容为空,仅有网站导航和营销链接
  • 无法从中获取关于pgvector或向量数据库的有效信息
#pgvector#向量数据库#Databricks#技术介绍
打开原文

What is pgvector? | Databricks

Skip to main content

[![Image 1](blob:http://localhost/c3d26385bd032c882a09c45135533626)](http://www.databricks.com/)

[![Image 2](blob:http://localhost/c3d26385bd032c882a09c45135533626)](http://www.databricks.com/)

  • Why Databricks
  • * Discover
  • Customers
  • Partners
  • Product
  • * Databricks Platform
  • Integrations and Data
  • Pricing
  • Open Source
  • Solutions
  • * Databricks for Industries
  • Cross Industry Solutions
  • Migration & Deployment
  • Solution Accelerators
  • Resources
  • * Learning
  • Events
  • Blog and Podcasts
  • Get Help
  • Dive Deep
  • About
  • * Company
  • Careers
  • Press
  • Security and Trust
  • DATA + AI SUMMIT ![Image 3: Data+ai summit promo JUNE 15–18|SAN FRANCISCO Last chance to save 50% — ends April 30. Register](http://www.databricks.com/dataaisummit?itm_source=www&itm_category=home&itm_page=home&itm_location=navigation&itm_component=navigation&itm_offer=dataaisummit)

1. Blog 2. / Data + AI Foundations 3. / Topic

  • * *

Contents in this story

How pgvector works

What is pgvector?

A PostgreSQL extension for storing and searching vector embeddings natively within your existing database.

Image 4: 4 Personas AI Agents 6

Data + AI Foundations8 min read

by Databricks Staff

Share this post

  • [](https://www.linkedin.com/shareArticle?mini=true&url=https://www.databricks.com/blog/what-is-pgvector&summary=&source=)
  • [](https://twitter.com/intent/tweet?text=https://www.databricks.com/blog/what-is-pgvector)
  • [](https://www.facebook.com/sharer/sharer.php?u=https://www.databricks.com/blog/what-is-pgvector)

Keep up with us

Subscribe

#### Summary

  • pgvector is a PostgreSQL extension that enables vector storage and similarity search directly within Postgres, eliminating the need for a separate vector database for most AI use cases like semantic search, RAG, and recommendations.
  • It supports multiple distance metrics, two index types (HNSW and IVFFlat), filtered search, and hybrid search, all natively within SQL, making it operationally simple for teams already on Postgres.
  • pgvector handles millions of vectors well, but performance degrades at very high scale; pgvectorscale and dedicated vector databases like Pinecone or Weaviate are the natural next steps as workloads grow.

pgvector is an open-source PostgreSQL extension that adds the ability to store, index and search vector embeddings (numerical representations of data). It brings vector data and similarity search into the same system that holds application data, making it possible to power semantic search, recommendations and retrieval-augmented generation (RAG) without relying on an external vector database. pgvector extends Postgres to support these AI-driven use cases.

Many modern AI applications depend on retrieving semantically similar data, not just exact matches. pgvector allows teams to perform this type of retrieval at runtime within their existing Postgres stack. For example, applications often need to retrieve content that is contextually similar to a query, even if the wording is different. This approach is often referred to as cosine similarity, nearest neighbor search or embedding-based search.

This article provides a high-level, educational overview of pgvector rather than detailed implementation guidance.

How pgvector works

pgvector adds a new data type to Postgres called `vector`. It allows embeddings, numerical representations of text, images or other content to be stored alongside relational data without requiring a separate system. These embeddings are typically generated by machine learning models that convert content such as text or images into numerical form.

At a high level, the process is simple. Embeddings are stored in the database. When a query is received, a query embedding is generated from the input, and pgvector returns the records whose vectors are most similar, or closest in meaning to that query. Instead of matching keywords, results are retrieved based on meaning.

pgvector determines similarity using distance metrics:

  • L2 (Euclidean distance): measures the distance between vectors, where smaller values indicate greater similarity
  • Cosine similarity: measures how closely vectors point in the same direction, which often reflects similarity in meaning
  • Inner product: measures alignment between vectors and is often used with normalized embeddings

Key features of pgvector

pgvector includes several features that make vector search practical within Postgres.

  • **Indexing:**Two index types are supported: HNSW and IVFFlat. HNSW prioritizes query speed and builds a graph structure in memory, but requires more memory. IVFFlat is more memory-efficient and partitions vectors into clusters using a training step, but queries may be slower.
  • **Distance metrics:** L2, cosine similarity and inner product cover most embedding-based use cases. Hamming distance supports binary vectors, and Jaccard distance supports sparse vectors in more specialized scenarios.
  • **Filtered search:** Vector similarity can be combined with standard relational filters. For example, results can include the most semantically similar products that are also in stock, within a price range or in a specific category.
  • **Hybrid search:**pgvector can be paired with Postgres full-text search to blend keyword and semantic search. This allows results to be both contextually relevant and textually precise in a single query.
  • **Additional data types:** Options such as `halfvec`, `sparsevec` and `bit` types help reduce memory usage when working with large embedding datasets.

Common use cases for pgvector

pgvector is widely used to power AI-driven application features:

Semantic search and RAG

Applications can retrieve documents or content based on meaning rather than keywords. This is a core component of retrieval-augmented generation (RAG), where large language models use retrieved context to generate accurate, relevant responses. Because pgvector runs similarity search directly within Postgres, this retrieval can happen in real time without requiring a separate system.

Recommendation systems

Items can be matched to past behavior or preferences to support recommendations. This pattern is commonly used for product recommendations, content discovery and personalization in applications. pgvector makes it efficient to identify related items based on patterns in user behavior or content.

Image similarity

Image embeddings can be stored and compared to quickly find visually similar images. This is widely used in media platforms, e-commerce and creative tools. Storing these embeddings alongside application data makes it easier to run similarity searches without additional infrastructure.

Anomaly detection

Outliers can be identified by finding data points that are distant from typical patterns in vector space. This is useful for fraud detection, monitoring and quality control. pgvector enables this by making it easy to compare vectors and detect deviations.

Deduplication

Duplicate or near-duplicate content can be identified, even when it is expressed differently or formatted in different ways. This is important for content management, search quality and data hygiene. Similarity-based comparison makes it possible to detect duplicates beyond exact matches.

pgvector vs. dedicated vector databases: when to use each

As vector search becomes part of more applications, teams often face a practical decision: should vector search stay within Postgres, or is a dedicated vector database needed? The answer depends on scale, performance requirements and operational complexity.

The differences can be summarized across key dimensions:

**Tool****Operational Complexity****Scalability Ceiling****Hybrid Query Support****Cost****Ecosystem Maturity** **pgvector****Lowest** (Existing DB)High (~100M+ vectors)**Best** (Native SQL Joins)Lowest (Included)High (Postgres ecosystem) **Pinecone**Low (Serverless/SaaS)**Highest** (Billions+)Moderate (Metadata only)High (Usage-based)High (AI-specific) **Weaviate**Moderate (Multi-modal)Very High High (GraphQL/Vector)Moderate High (Open-source) **Qdrant**Moderate (Rust-based)Very High High (Filtering-heavy)Moderate Growing Fast

pgvector is the natural starting point for teams already using Postgres and operating below the scale ceiling. It works well when vector search is part of an existing application workflow and data volumes or query demands remain manageable. Dedicated vector databases become more relevant when query volume, recall requirements or multi-tenant workloads push beyond what Postgres can efficiently support.

pgvectorscale

pgvectorscale is designed for teams that want to extend how far they can go with pgvector before adopting a dedicated vector database. It addresses the performance and scalability challenges that arise as data volumes and query demands increase, particularly around indexing speed and query latency. By improving how pgvector performs at larger scales, it allows teams to continue using Postgres for longer without re-architecting their systems. This makes it a practical intermediate step for applications approaching the limits of what pgvector can handle on its own.

REPORT

The agentic AI playbook for the enterprise

Read now

Image 6: psty

Limitations and scaling considerations

pgvector is powerful, but it comes with tradeoffs:

  • Performance can degrade at very high vector counts (10M+) without additional optimization or tooling
  • HNSW indexes are memory-intensive, and large deployments may require significant RAM
  • Postgres does not provide built-in sharding for vector workloads, so horizontal scaling requires external tooling or a managed provider
  • Search speed and recall involve a real tradeoff. Recall — the percentage of truly relevant results that are returned — requires deliberate configuration to optimize.

Understanding these limitations helps determine when pgvector is sufficient and when additional infrastructure may be needed.

Getting started with pgvector

pgvector can be installed on macOS and most Linux distributions using standard package managers such as Homebrew. It is also available on many managed Postgres platforms, including AWS RDS, Supabase, Azure Database for PostgreSQL, Google Cloud SQL and Neon.

Installation and setup instructions are available in the official pgvector GitHub repository, which includes step-by-step guidance maintained by the project’s authors.

Databricks customers using Postgres can also reference the Databricks OLTP extensions docs for platform-specific guidance.

pgvector and the modern AI data stack

pgvector operates in the operational serving layer of an AI system, where low-latency retrieval is required at application runtime. It is commonly used to support semantic search, recommendations and retrieval-augmented generation (RAG) within applications.

In contrast, Databricks Mosaic AI Vector Search is better suited for large-scale, batch-processed AI workloads, where data pipelines are managed in the lakehouse. These environments support centralized data processing, large datasets and complex workflows.

These approaches are complementary, and teams often use both across different layers of the stack. pgvector supports real-time application queries, while platforms like Databricks handle large-scale data preparation, embedding generation and model-driven workflows.

Frequently asked questions

**Is pgvector a full vector database?**

pgvector enables Postgres to store embeddings and perform similarity search directly on that data. However, it is not a purpose-built vector database. Dedicated vector databases provide additional scalability and performance optimizations for larger workloads.

**What is the difference between HNSW and IVFFlat in pgvector?**

HNSW is optimized for fast query performance and uses an in-memory graph structure, which requires more memory. IVFFlat has a lower memory footprint and organizes vectors into clusters through a training step, but performance can vary depending on the dataset and workload. The choice depends on whether speed or memory efficiency is the priority.

**How many vectors can pgvector handle?**

pgvector can typically handle millions to tens of millions of vectors, depending on hardware, indexing strategy and query patterns. As datasets grow, performance may decline without careful tuning or additional tooling. Factors such as available memory, index type and query frequency all influence scalability.

**Does pgvector support cosine similarity?**

Yes, pgvector supports cosine similarity as one of its primary distance metrics. It measures how closely two vectors point in the same direction, which often reflects semantic similarity in embedding-based applications. This makes it well suited for semantic search, recommendation systems and natural language processing.

**Is pgvector free and open source?**

Yes, pgvector is an open-source project released under a permissive license. It can be used with standard Postgres installations as well as many managed Postgres services. This makes it an accessible starting point for adding vector search capabilities.

**Can pgvector do hybrid search?**

Yes, pgvector can be combined with Postgres full-text search to support hybrid search. This allows results to balance semantic relevance with keyword matching, improving both accuracy and usability. Hybrid search is especially useful in scenarios such as product search and documentation search, where both meaning and exact terms are important.

Choosing the right vector search approach

pgvector is a practical starting point for any team that wants to add vector search to an existing Postgres application. By storing embeddings alongside relational data and supporting similarity search natively within the database, it removes the operational overhead of managing a separate vector store. For many workloads — semantic search, RAG pipelines, recommendations and anomaly detection — it delivers what teams need without requiring a new system.

As data volumes grow or query demands increase, pgvectorscale can extend how far teams go before a dedicated vector database becomes necessary. For organizations managing large-scale AI workloads across a unified data platform, Databricks Mosaic AI Vector Search offers a complementary approach designed for the lakehouse layer. Together, these tools give teams the flexibility to match their vector search infrastructure to their actual workload requirements — at any scale.

Keep up with us

Subscribe

Contents in this story

How pgvector works

Recommended for you

Image 8: 4 Personas AI Agents 1b

Data + AI Foundations

14 min read

#### What is a PostgreSQL Database?

Image 10: 4 Personas AI Agents 6

Data + AI Foundations

12 min read

#### What is Retrieval Augmented Generation (RAG)?

Image 12: 4 Personas AI Agents 4b

Data + AI Foundations

6 min read

#### What are Machine Learning Models?

Share this post

  • [](https://www.linkedin.com/shareArticle?mini=true&url=https://www.databricks.com/blog/what-is-pgvector&summary=&source=)
  • [](https://twitter.com/intent/tweet?text=https://www.databricks.com/blog/what-is-pgvector)
  • [](https://www.facebook.com/sharer/sharer.php?u=https://www.databricks.com/blog/what-is-pgvector)

Never miss a Databricks post

Subscribe to our blog and get the latest posts delivered to your inbox

Sign up

*

Work Email

*

Country Country*

By clicking “Subscribe” I understand that I will receive Databricks communications, and I agree to Databricks processing my personal data in accordance with its Privacy Policy.

Subscribe

What's next?

More from the Authors

Image 14: Google Cloud Use Cases: How Enterprises Run Data & AI on GCP with Databricks

Data + AI Foundations

29 min read

#### Google Cloud Use Cases: How Enterprises Run Data & AI on GCP with Databricks

Image 16: 10 Personas Data Management

Data + AI Foundations

12 min read

#### What is a Cloud-Based Database Management System?

![Image 18: databricks logo](https://www.databricks.com/)

Why Databricks

Discover

Customers

Partners

Why Databricks

Discover

Customers

Partners

Product

Databricks Platform

Pricing

Open Source

Integrations and Data

Product

Databricks Platform

Pricing

Open Source

Integrations and Data

Solutions

Databricks For Industries

Cross Industry Solutions

Data Migration

Professional Services

Solution Accelerators

Solutions

Databricks For Industries

Cross Industry Solutions

Data Migration

Professional Services

Solution Accelerators

Resources

Documentation

Customer Support

Community

Learning

Events

Blog and Podcasts

Resources

Documentation

Customer Support

Community

Learning

Events

Blog and Podcasts

About

Company

Careers

Press

Security and Trust

About

Company

Careers

Press

Security and Trust

![Image 20: databricks logo](https://www.databricks.com/)

Databricks Inc.

160 Spear Street, 15th Floor

San Francisco, CA 94105

1-866-330-0121

  • [](https://www.linkedin.com/company/databricks)
  • [](https://www.facebook.com/pages/Databricks/560203607379694)
  • [](https://twitter.com/databricks)
  • [](https://www.databricks.com/feed)
  • [](https://www.glassdoor.com/Overview/Working-at-Databricks-EI_IE954734.11,21.htm)
  • [](https://www.youtube.com/@Databricks)
Image 22

See Careers

at Databricks

  • [](https://www.linkedin.com/company/databricks)
  • [](https://www.facebook.com/pages/Databricks/560203607379694)
  • [](https://twitter.com/databricks)
  • [](https://www.databricks.com/feed)
  • [](https://www.glassdoor.com/Overview/Working-at-Databricks-EI_IE954734.11,21.htm)
  • [](https://www.youtube.com/@Databricks)

© Databricks 2026. All rights reserved. Apache, Apache Spark, Spark, the Spark Logo, Apache Iceberg, Iceberg, and the Apache Iceberg logo are trademarks of the Apache Software Foundation.

We Care About Your Privacy

Databricks uses cookies and similar technologies to enhance site navigation, analyze site usage, personalize content and ads, and as further described in our Cookie Notice. To disable non-essential cookies, click “Reject All”. You can also manage your cookie settings by clicking “Manage Preferences.”

Manage Preferences

Reject All Accept All

Image 25: Databricks Company Logo

Privacy Preference Center

Opt-Out Preference Signal Honored

Privacy Preference Center

  • ### Your Privacy
  • ### Strictly Necessary Cookies
  • ### Performance Cookies
  • ### Functional Cookies
  • ### Targeting Cookies
  • ### TOTHR

#### Your Privacy

When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.

#### Opting out of sales, sharing, and targeted advertising

Depending on your location, you may have the right to opt out of the “sale” or “sharing” of your personal information or the processing of your personal information for purposes of online “targeted advertising.” You can opt out based on cookies and similar identifiers by disabling optional cookies here. To opt out based on other identifiers (such as your email address), submit a request in our Privacy Request Center.

More information

#### Strictly Necessary Cookies

Always Active

These cookies are necessary for the website to function and cannot be switched off in our systems. They assist with essential site functionality such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will no longer work.

#### Performance Cookies

  • [x] Performance Cookies

These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site.

#### Functional Cookies

  • [x] Functional Cookies

These cookies enable the website to provide enhanced functionality and personalization. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.

#### Targeting Cookies

  • [x] Targeting Cookies

These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant advertisements on other sites. If you do not allow these cookies, you will experience less targeted advertising.

#### TOTHR

  • [x] TOTHR

Cookie List

Consent Leg.Interest

  • [x] checkbox label label
  • [x] checkbox label label
  • [x] checkbox label label

Clear

  • - [x] checkbox label label

Apply Cancel

Confirm My Choices

Allow All

![Image 26: Powered by Onetrust](https://www.onetrust.com/products/cookie-consent/)

!Image 28!Image 29

Image 30
Image 31

问问这篇内容

回答仅基于本篇材料
    0 / 500

    Skill 包

    领域模板,一键产出结构化笔记
    • 论文精读包

      把一篇论文 / 技术博客精读成结构化笔记:问题、方法、实验、批判、延伸阅读。

      • · TL;DR(1 段)
      • · 研究问题与动机
      • · 方法概览
    • 投融资雷达包

      把一条融资 / 创投新闻整理成投资人视角的雷达卡:交易要点、判断、竞争格局、风险、尽调清单。

      • · 交易要点(公司 / 轮次 / 金额 / 投资人 / 估值,材料未明示则写 “未披露”)
      • · 投资 thesis(这家公司为什么值得关注)
      • · 竞争格局与替代方案

    导出到第二大脑

    支持 Notion / Obsidian / Readwise
    下载 Markdown(Obsidian 直接拖入)