跳到主要内容Skip to main content
RAG 与知识库RAG & Knowledge Bases生产可用Production

pgvector

pgvector / pgvector

Postgres 的向量扩展,给普通表加 vector 列、距离操作符和 HNSW/IVFFlat 索引,让向量检索和业务数据留在同一个库。A Postgres extension that adds vector columns, distance operators and HNSW or IVFFlat indexes, keeping vector search next to business data.

23.7k stars 1401 forks C 语言Language NOASSERTION 许可License 最近推送Last push 2026-11-20

为什么选Why choose it

  • RAG 最省运维的起点:事务、权限、备份、SQL 过滤和向量检索一体,不必先上专用向量库。One database for relational and vector data.
  • HNSW 索引成熟,千万级向量以内通常够用,还能和结构化条件组合查询。Transactions and permissions reuse Postgres.
  • 生态广,LangChain、LlamaIndex、Django、Rails 等都有现成适配。HNSW and IVFFlat indexes are supported.

不适合Not for

十亿级向量、极高 QPS 或需要独立扩缩容的大规模场景。You need a dedicated vector database at very large scale.
需要多租户物理隔离或专门向量检索高级功能的团队。Your Postgres instance cannot be extended.

最小上手Minimum setup

  1. 在 Postgres 13+ 安装 vector 扩展并 CREATE EXTENSION vector。Create a vector column and insert 10k rows.
  2. 建一张带 vector(768) 列的表,插入几条 embedding 做距离查询。Build an HNSW index and compare recall and latency.
  3. 加 HNSW 索引,用 1 万–10 万条真实数据测 recall 与延迟。Test a filtered query that combines SQL and vector distance.

依赖与成本Dependencies and cost

PostgreSQL 13+;编译扩展需要 pg_config;应用侧任意语言驱动。Check runtime, model weights and external service dependencies in the README.

许可与使用边界License and usage boundaries

PostgreSQL License;数据库与 embedding 模型另计。Code is NOASSERTION; model weights, training data and generated content may have separate terms — check each before commercial use.

开源不等于可商用:GPL / AGPL 有传染性;代码许可、模型许可、生成内容许可要分开看。上线前读仓库 LICENSE 与模型卡,必要时让法务确认。Open source is not automatically commercial-use friendly: GPL / AGPL are copyleft; code, model and output licenses are separate. Read the LICENSE and model card before launch, and involve legal when needed.

替代与相邻Alternatives and neighbors

  • LanceDB — 本地优先Local-first,嵌入式多模态向量数据库,Rust 核心 + Python/JS SDK,底层 Lance 列存,支持向量、全文、SQL 过滤和版本化。An embedded multimodal vector database with a Rust core and Python/JavaScript SDKs, built on Lance columnar storage with vector, full-text, SQL filtering and versioning.
  • Qdrant — 生产可用Production,Rust 写的向量数据库,带过滤、混合检索、分布式与量化。A Rust vector database with filtering, hybrid search, distributed deployment and quantisation.
  • Milvus — 规模 / 性能Scale / performance,面向大规模向量检索的分布式数据库,支持 HNSW/IVF/DiskANN 等索引、标量过滤与多租户。A distributed vector database for large-scale retrieval, supporting HNSW, IVF, DiskANN, scalar filtering and multi-tenancy.

下一步Next steps

  • 打开 GitHub,先读 README、LICENSE、最近 release 与 issue。Open GitHub and read the README, LICENSE, latest release and issues first.
  • 按“部署依赖 / 显存 / 数据 / 网络 / 权限”列一张上手清单。Make an onboarding checklist for deployment dependencies, VRAM, data, network and permissions.
  • 用一个小样本跑通,再决定是否进生产;不要直接上生产数据。Run a small sample first, then decide on production; never start with production data.

GitHub 仓库 ↗GitHub repository ↗ 文档 ↗Docs ↗ 加入对比Add to compare

快照口径:stars / forks / language / license / pushed_at 来自 GitHub API 2026-11-20 快照;之后的变化没有回写。标签与“适合 / 不适合”是编辑判断,不是 GitHub 元数据。Snapshot: stars / forks / language / license / pushed_at come from the GitHub API snapshot on 2026-11-20; later changes are not written back. Tags and “fit / not fit” are editorial judgments, not GitHub metadata.
不背书:本站只做索引与风险提示,不审计代码、不保证安全、不替你做许可判断。仓库脚本与模型权重请自行审查。No endorsement: this site only indexes and flags risks; it does not audit code, guarantee security or make license decisions for you. Review repository scripts and model weights yourself.