# pgvectorscale

> A PostgreSQL extension that builds on pgvector with a StreamingDiskANN index, Statistical Binary Quantization, and label-filtered vector search.

pgvectorscale is an open-source PostgreSQL extension from Timescale that complements pgvector with higher-performance embedding search and more cost-efficient storage for AI applications. It adds a StreamingDiskANN index, Statistical Binary Quantization compression, and label-based filtered vector search. It is written in Rust using the PGRX framework and released under the PostgreSQL License.

## What It Is

pgvectorscale is a vector search extension for PostgreSQL that works alongside pgvector. Application developers and DBAs create a table with a vector column, then build a `diskann` index on it and query with the same distance operators pgvector uses: cosine (`<=>`), L2 (`<->`), and inner product (`<#>`), each matched to its operator class.

The README states that on a benchmark of 50 million Cohere embeddings with 768 dimensions, PostgreSQL with pgvector and pgvectorscale achieved 28x lower p95 latency and 16x higher query throughput than Pinecone's storage-optimized (s1) index at 99% recall, at 75% less cost when self-hosted on AWS EC2.

## Index and Filtering Model

The StreamingDiskANN index is inspired by Microsoft's DiskANN research. By default it uses the `memory_optimized` storage layout, which compresses vectors with Statistical Binary Quantization; a `plain` layout stores them uncompressed. Label-based filtering takes a `smallint[]` labels column in the index definition and uses the `&&` overlap operator for filtered queries. Arbitrary WHERE clauses are also supported, but they are applied as post-filtering after the vector search.

## Tuning and Behavior Notes

Build-time parameters include `num_neighbors`, `search_list_size`, `max_alpha`, `num_dimensions` (useful for Matryoshka embeddings), and `num_bits_per_dimension`. Parallel index builds are supported under documented conditions, for example when the table has no labels and SBQ storage is used. At query time, `diskann.query_search_list_size` and `diskann.query_rescore` trade accuracy against speed.

Documented limitations:
- Results can be slightly out of distance order (relaxed ordering), and a materialized CTE restores strict ordering.
- Null vectors are not indexed.
- Indexes on UNLOGGED tables are not supported.
- Building from source on Intel (x86) macOS is not supported.

## Setup Path

You can run it from a pre-built TimescaleDB Docker image, build from source with Rust and cargo-pgrx, or enable it in a Timescale Cloud service. In each case, `CREATE EXTENSION IF NOT EXISTS vectorscale CASCADE;` also installs pgvector.

## Features
- StreamingDiskANN index for vector search
- Statistical Binary Quantization compression
- Label-based filtered vector search
- Post-filtering with arbitrary WHERE clauses
- Cosine, L2 and inner product distance queries
- Parallel index builds
- Tunable build-time and query-time parameters
- Matryoshka embedding support via num_dimensions
- Written in Rust with PGRX

## Integrations
PostgreSQL, pgvector, TimescaleDB, Timescale Cloud, Docker

## Platforms
MACOS, LINUX, API

## Pricing
Open Source

## Version
0.9.1

## Links
- Website: https://github.com/timescale/pgvectorscale
- Repository: https://github.com/timescale/pgvectorscale
- EveryDev.ai: https://www.everydev.ai/tools/pgvectorscale
