# VectorChord

> Disk-friendly, billion-scale vector search inside PostgreSQL

- Category: Retrieval & Knowledge (RAG) / Vector Databases
- Language: Rust
- Repository: https://github.com/supervc-stack/VectorChord
- Website: https://vectorchord.ai
- Canonical page: https://ai-tldr.dev/tools/vectorchord/

## In short

VectorChord (vchord) is a PostgreSQL extension for vector similarity search. It is the successor to pgvecto.rs and works with the same vector data types and SQL syntax as pgvector, so existing pgvector tables and queries keep working. It sits in the Vector Databases category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Rust.

## Overview

VectorChord (vchord) is a PostgreSQL extension for vector similarity search. It is the successor to pgvecto.rs and works with the same vector data types and SQL syntax as pgvector, so existing pgvector tables and queries keep working. It uses RaBitQ compression with automatic reranking to store large numbers of vectors cheaply while keeping search quality high.

It is aimed at teams who already run PostgreSQL and want to keep their vector data in the same database instead of adding a separate vector store. Because it reuses pgvector's `vector` type and the standard `ORDER BY embedding <-> ...` distance query, migrating an application is mostly a matter of installing the extension and creating a new index.

Within the vector-database category, VectorChord focuses on disk-based storage and large scale: the project reports hosting 100M vectors on a single AWS instance and building 100M-vector indexes in around 20 minutes, with index sizes that fit in memory budgets typical of one machine.

## What it does

- Compatible with pgvector data types and syntax, so existing tables and queries migrate with little change
- RaBitQ compression plus automatic reranking to store many more vectors per dollar of storage
- The `vchordrq` index type for approximate nearest-neighbor search on a vector column
- Native low-bit vector types (4-bit RaBitQ4 and 8-bit RaBitQ8) to cut storage further
- Disk-friendly design that targets 100M+ vectors on a single machine and scales toward 1B+
- Fast index builds using hierarchical K-means and optimized disk operations

## Getting started

The quickest path is the official Docker image, then connect with psql and enable the extension.

1. Run the Docker image

   Start a PostgreSQL container that already includes the VectorChord extension.

```bash
docker run \
  --name vectorchord-demo \
  -e POSTGRES_PASSWORD=mysecretpassword \
  -p 5432:5432 \
  -d ghcr.io/tensorchord/vchord-postgres:pg18-v1.1.1
```

2. Connect with psql

   Connect to the database. The default user is postgres and the password is the one you set above.

```bash
psql -h localhost -p 5432 -U postgres
```

3. Enable the extension

   Create the vchord extension. CASCADE also pulls in pgvector, which VectorChord depends on.

```sql
CREATE EXTENSION IF NOT EXISTS vchord CASCADE;
```

4. Create a table, index, and search

   Make a table with a vector column, build a vchordrq index, then run a nearest-neighbor query.

```sql
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
INSERT INTO items (embedding) SELECT ARRAY[random(), random(), random()]::real[] FROM generate_series(1, 1000);

CREATE INDEX ON items USING vchordrq (embedding vector_l2_ops);

SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;
```

## When to use it

- Adding semantic or similarity search to an app that already uses PostgreSQL, without running a separate vector database
- Migrating from pgvector or pgvecto.rs while keeping the same vector types and SQL queries
- Storing tens or hundreds of millions of embeddings on a single machine while controlling storage cost
- Building a retrieval layer for RAG or recommendation features alongside existing relational data
