百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
P

pgvecto.rs

> 数据库
开源

Postgres 中的可扩展、低延迟和混合式支持的向量搜索。彻底改变向量搜索,而非数据库。

2.2K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Postgres 中的可扩展、低延迟和混合式支持的向量搜索。彻底改变向量搜索,而非数据库。

`pgvecto.rs` is a Postgres extension that provides vector similarity search functions. It is written in Rust and based on [pgrx](https://github.com/pgcentralfoundation/pgrx). > [!NOTE] > We have a new implementation [VectorChord](https://github.com/tensorchord/VectorChord/) with better stability and performance. Users are encouraged to migrate to VectorChord. Check out the [migration guide](https://docs.vectorchord.ai/vectorchord/admin/migration.html). ## Comparison with pgvector Checkout [pgvecto.rs vs pgvector](https://docs.vectorchord.ai/faqs/comparison-pgvector.html) for more details. | Feature | pgvecto.rs | pgvector | | --- | --- | --- | | Filtering | Introduces VBASE method for vector search and relational query (e.g. Single-Vector TopK + Filter + Join). | When filters are applied, the results may be incomplete. For example, if you originally intended to limit the results to 10, you might end up with only 5 results with filters. | | Vector Dimensions | Supports up to 65535 dimensions. | Supports up to 2000 dimensions. | | SIMD | SIMD instructions are dynamically dispatched at runtime to maximize performance based on the capabilities of the specific machine. | Added CPU dispatching for distance functions on Linux x86-64" in 0.7.0. | | Data Types | Introduces additional data types: binary vectors, FP16 (16-bit floating point), and INT8 (8-bit integer). | \- | | Indexing | Handles the storage and memory of indexes separately from PostgreSQL | Relies on the native storage engine of PostgreSQL | | WAL Support | Provides Write-Ahead Logging (WAL) support for data, index support is working in progress. | Provides Write-Ahead Logging (WAL) support for index and data. | | ## [Documentation](https://docs.vectorchord.ai/getting-started/overview.html) - Getting Started - [Overview](https://docs.vectorchord.ai/getting-started/overview.html) - [Installation](https://docs.vectorchord.ai/getting-started/installation.html) - Usage - [Indexing](https://docs.vectorchord.ai/usage/indexing.html) - [Search](https://docs.vectorchord.ai/usage/search.html) - Administration - [Configuration](https://docs.vectorchord.ai/admin/configuration.html) - [Upgrading from older versions](https://docs.vectorchord.ai/admin/upgrading.html) - Developers - [Development Tutorial](https://docs.vectorchord.ai/developers/development.html) ## Quick start For new users, we recommend using the [Docker image](https://github.com/tensorchord/pgvecto.rs/pkgs/container/pgvecto-rs) to get started quickly. ```sh docker run \ --name pgvecto-rs-demo \ -e POSTGRES_PASSWORD=mysecretpassword \ -p 5432:5432 \ -d ghcr.io/tensorchord/pgvecto-rs:pg17-v0.4.0 ``` Then you can connect to the database using the `psql` command line tool. The default username is `postgres`, and the default password is `mysecretpassword`. ```sh psql -h localhost -p 5432 -U postgres ``` Run the following SQL to ensure the extension is enabled. ```sql DROP EXTENSION IF EXISTS vectors; CREATE EXTENSION vectors; ``` pgvecto.rs introduces a new data type `vector(n)` denoting an n-dimensional vector. The `n` within the brackets signifies the dimensions of the vector. You could create a table with the following SQL. ```sql -- create table with a vector column CREATE TABLE items ( id bigserial PRIMARY KEY, embedding vector(3) NOT NULL -- 3 dimensions ); ``` > [!TIP] >`vector(n)` is a valid data type only if $1 \leq n \leq 65535$. Due to limits of PostgreSQL, it's possible to create a value of type `vector(3)` of $5$ dimensions and `vector` is also a valid data type. However, you cannot still put $0$ scalar or more than $65535$ scalars to a vector. If you use `vector` for a column or there is some values mismatched with dimension denoted by the column, you won't able to create an index on it. You can then populate the table with vector data as follows. ```sql -- insert values INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]'); -- or insert values using a casting from array to vector INSERT INTO items (embedding) VALUES (ARRAY[1, 2, 3]::real[]), (ARRAY[4, 5, 6]::real[]); ``` We support three operators to calculate the distance between two vectors. - `<->`: squared Euclidean distance, defined as $\Sigma (x_i - y_i) ^ 2$. - `<#>`: negative dot product, defined as $- \Sigma x_iy_i$. - `<=>`: cosine distance, defined as $1 - \frac{\Sigma x_iy_i}{\sqrt{\Sigma x_i^2 \Sigma y_i^2}}$. ```sql -- call the distance function through operators -- squared Euclidean distance SELECT '[1, 2, 3]'::vector <-> '[3, 2, 1]'::vector; -- negative dot product SELECT '[1, 2, 3]'::vector <#> '[3, 2, 1]'::vector; -- cosine distance SELECT '[1, 2, 3]'::vector <=> '[3, 2, 1]'::vector; ``` You can search for a vector simply like this. ```sql -- query the similar embeddings SELECT * FROM items ORDER BY embedding <-> '[3,2,1]' LIMIT 5; ``` ### A simple Question-Answering application Please check out the [Question-Answering application](https://docs.vectorchord.ai/use-case/question-answering.html) tutorial. ### Half-precision floating-point `vecf16` type is the same with `vector` in anything but the scalar type. It stores 16-bit floating point numbers. If you want to reduce the memory usage to get better performance, you can try to replace `vector` type with `vecf16` type. ## Roadmap ️ Please check out [ROADMAP](https://docs.vectorchord.ai/community/roadmap.html). Want to jump in? Welcome discussions and contributions! - Chat with us on [ Discord](https://discord.gg/KqswhpVgdU) - Have a look at [`good first issue `](https://github.com/tensorchord/pgvecto.rs/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue+%E2%9D%A4%EF%B8%8F%22) issues! ## Contribute We welcome all kinds of contributions from the open-source community, individuals, and partners. - Join our [discord community](https://discord.gg/KqswhpVgdU)! - To build from the source, please read our [contributing documentation](https://docs.vectorchord.ai/community/contributing.html) and [development tutorial](https://docs.vectorchord.ai/developers/development.html). ## Contributors ✨ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Alex Chi


AuruTus


Avery


Ben Ye


Ce Gao


Jinjing Zhou


Joe Passanante


Keming


Mingzhuo Yin

⚠️
Usamoi


cutecutecat


odysa


yi wang


yihong


盐粒 Yanli

Add your contributions This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! ## Acknowledgements Thanks to the following projects: - [pgrx](https://github.com/tcdi/pgrx) - Postgres extension framework in Rust - [pgvector](https://github.com/pgvector/pgvector) - Postgres extension for vector similarity search written in C

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •Getting Started
  • •Overview
  • •Installation
  • •Indexing
  • •Administration
  • •Configuration
  • •Upgrading from older versions
  • •Developers
  • •Development Tutorial
  • •<->: squared Euclidean distance, defined as $\Sigma (x_i - y_i) ^ 2$.

> 标签

Rustchatgptfaissgpthacktoberfest

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库