pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: zthhhhh (@zthhhhh) <noreply+zthhhhh@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #1003: Support RabitQ in pgvector
Date: Thu, 30 Jul 2026 06:58:55 +0000
Message-ID: <gh-pgvector-pgvector-1003-c5127663318@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-1003@github.com>
References: <gh-pgvector-pgvector-1003@github.com>

Thanks @ankane , I have added the index sizes and build times to the comparison.

## Index build and size

The following results use the same dataset and index parameters as the query benchmarks shared above.

| Access method | Implementation | Build time | Index size |
| --- | --- | ---: | ---: |
| IVFFlat | without quantization | 214.71 s | 7820 MB |
| IVFFlat | RaBitQ | 181.74 s | 256 MB |
| IVFFlat | halfvec + binary quantization | 42.88 s | 210 MB |
| HNSW | without quantization | 644.34 s | 7813 MB |
| HNSW | RaBitQ | 1372.24 s | 2640 MB |
| HNSW | halfvec + binary quantization | 82.82 s | 479 MB |

## RaBitQ integration
> I'm not sure the difference will be worth the complexity. 

I understand that minimizing the impact on the existing file is also an important consideration.

For RaBitQ, the current design reuses the existing IVFFlat and HNSW access methods rather than introducing new access methods. The quantization method is reported through the existing type support functions:

- Support function 5 for IVFFlat
- Support function 3 for HNSW

The access methods use this metadata to select the corresponding index representation, distance evaluation, and refinement paths.
This avoids duplicating the existing access methods and requires only limited changes to the existing file.

## Asymmetric binary quantization

> I think it'd also be good to try asymmetric binary quantization (quantize the indexed vectors but not the query vector) to see how it compares.

My understanding of the suggested asymmetric binary quantization approach is that indexed vectors remain binary-quantized while 
the query vector remains an unquantized `vector` or `halfvec`.

pgvector currently provides Hamming distance between two `bit` values, but it does not provide a distance operator between a binary-quantized vector and a vector. This could be implemented by adding an asymmetric distance function and registering the corresponding operator and operator class. The index and query would conceptually look like this:

```sql
CREATE INDEX items_embedding_idx ON items USING hnsw (
    (binary_quantize(embedding)::bit(1536))
    ${asymmetric_binary_operator_class}
);

SELECT id
FROM items
ORDER BY binary_quantize(embedding)::bit(1536)
         ${asymmetric_binary_operator} ${query_vector}
LIMIT 10;
```

Compared with symmetric Hamming distance, this is expected to improve recall before re-ranking because the full values of the query vector are retained in the distance calculation. It provides a tradeoff between symmetric binary quantization and unquantized distance computation.

Since `binary_quantize` already determines the indexed representation, this should mainly require a new distance function, operator, and operator class, without changes to the existing HNSW or IVFFlat access method handlers. I think that this is a worthwhile comparison and would be happy to provide an implementation as a pull request.

Thank you for all your work on maintaining and improving pgvector.

view thread (12+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-1003-c5127663318@github.com>
Permalink:  ../gh-pgvector-pgvector-1003-c5127663318@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox