# pgvectorscale

> A DiskANN-based index that scales pgvector search on PostgreSQL

- Category: Retrieval & Knowledge (RAG) / Vector Databases
- Language: Rust
- Licence: PostgreSQL
- Repository: https://github.com/timescale/pgvectorscale
- Canonical page: https://ai-tldr.dev/tools/pgvectorscale/

## In short

pgvectorscale is a PostgreSQL extension that complements pgvector, the open-source vector data extension for Postgres. It adds a StreamingDiskANN index type, inspired by Microsoft's DiskANN algorithm, along with Statistical Binary Quantization for compact storage and label-based filtered vector search. It sits in the Vector Databases category of the Retrieval & Knowledge (RAG) tools and is open-source, written in Rust and licensed PostgreSQL.

## Overview

pgvectorscale is a PostgreSQL extension that complements pgvector, the open-source vector data extension for Postgres. It adds a StreamingDiskANN index type, inspired by Microsoft's DiskANN algorithm, along with Statistical Binary Quantization for compact storage and label-based filtered vector search.

It is meant for application developers and DBAs who already store embeddings in PostgreSQL with pgvector and want approximate nearest neighbor search to stay fast and affordable as data grows into the tens of millions of vectors. You keep your data in Postgres instead of moving it to a separate vector database.

Unlike pgvector, which is written in C, pgvectorscale is built in Rust using the PGRX framework. It installs as the `vectorscale` extension and works alongside pgvector, so you create indexes and run queries with familiar SQL and pgvector distance operators. In October 2026 Tiger Data said pgvectorscale would enter maintenance mode, with most new vector-search work moving to its partition-based pg_vectorsearch extension.

## What it does

- StreamingDiskANN index, a disk-friendly graph index inspired by Microsoft's DiskANN research
- Statistical Binary Quantization for compact storage and faster search than standard binary quantization
- Label-based filtered vector search that combines similarity search with label filtering
- Works as a complement to pgvector, reusing its VECTOR type and distance operators (<=>, <->, <#>)
- Self-hosted on your own PostgreSQL, available via Docker, source build, or Timescale Cloud
- Written in Rust with PGRX, giving the Postgres community another way to contribute to vector support

## Getting started

Install the extension, enable it in your database, then create a StreamingDiskANN index on an embedding column and query it with pgvector operators.

1. Run PostgreSQL with the extension

   The quickest path is the TimescaleDB Docker image, which bundles pgvectorscale. Then connect with psql.

```bash
psql -d "postgres://<username>:<password>@<host>:<port>/<database-name>"
```

2. Create the extension

   Enable vectorscale. CASCADE automatically installs pgvector as well.

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

3. Create a table with an embedding column

   Store your embeddings in a VECTOR column using the pgvector type.

```sql
CREATE TABLE IF NOT EXISTS document_embedding (
    id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
    metadata JSONB,
    contents TEXT,
    embedding VECTOR(1536)
);
```

4. Add a StreamingDiskANN index and query it

   Create a diskann index, then run a nearest neighbor search with the cosine distance operator.

```sql
CREATE INDEX document_embedding_idx ON document_embedding
USING diskann (embedding vector_cosine_ops);

SELECT *
FROM document_embedding
ORDER BY embedding <=> $1
LIMIT 10;
```

## When to use it

- Scaling an existing pgvector setup to tens of millions of embeddings while keeping low query latency
- Keeping vector search inside PostgreSQL instead of running a separate vector database
- Combining vector similarity with label filtering for more precise retrieval in a RAG pipeline
- Reducing storage cost for large embedding tables using binary quantization
