This is not an officially supported Google product. This project is not eligible for the Google Open Source Software Vulnerability Rewards Program.
This repository contains benchmarks for filtered vector search algorithms (HNSW, ACORN) implemented in:
- C++ / HNSWLib — in-memory index tests comparing ACORN vs HNSW
sweeping. See
third_party/fvsb_hnswlib/README.md. - PostgreSQL — via a custom
pgvectorextension (see PostgreSQL section below).
Check out more details in our SIGMOD 2026 paper. If you use our work, please cite:
An In-Depth Study of Filter-Agnostic Vector Search on a PostgreSQL Database System
Duo Lu, Helena Caminal, Manos Chatzakis, Yannis Papakonstantinou, Yannis Chronis, Vaibhav Jain, Fatma Özcan.
SIGMOD 2026
git,wget,make,gcc,g++(supporting C++20)python3,pippkg-config(for HDF5 detection)
Python dependencies:
pip install numpy scipy h5py torch tqdmAll configuration is centralized in a .env file at the repository root.
Create one from the provided template:
cp .env.template .env
# Edit .env with your dataset paths and preferencesThe C++ binaries (benchmark_runner, acorn_fvs_bitmap_test) auto-load .env
from the working directory on startup — no need to export variables each
session. For Python scripts, source the file first:
source .env && python3 -m gen_workloads.convert_fvecs_to_hdf5 --dataset sift1MShell-exported variables take precedence over .env values. If neither is set,
built-in defaults are used (e.g., FVS_DATA_DIR=data).
See .env.template for the full list of variables.
This is the fastest way to run ACORN vs HNSW filtered search tests.
cd build
./setup_hnswlib_env.shThis downloads dependencies and compiles both the benchmark runner and the
ACORN test binary into $HOME/fvsb_hnswlib_build/.
If you have an existing fvecs dataset (e.g., sift1M):
# Make sure .env is configured (see Environment Setup above)
source .env
python3 -m gen_workloads.convert_fvecs_to_hdf5 --dataset sift1MExpected input layout at $FVS_DATA_DIR/sift/:
sift_base.fvecs
sift_query.fvecs
sift_groundtruth.ivecs
This creates:
$FVS_DATA_DIR/sift1M-128-euclidean.hdf5— for the C++ test$FVS_DATA_DIR/datasets/sift1M/sift1M.{index,test}.fvecs— for bitmap generation
Edit gen_workloads/gen_bitmaps.py and set DATASETS_TO_GEN_BITMAPS to
include only your dataset (e.g., ["sift1M"]), then run:
python3 -m gen_workloads.gen_bitmapsSee gen_workloads/README.md for details.
cd $HOME/fvsb_hnswlib_build
./acorn_fvs_bitmap_testThe binary auto-loads .env from the working directory (the build script
copies it there during setup). No manual export needed.
The test loads the dataset and bitmaps, builds HNSW + ACORN indexes, and reports recall/latency/speedup at each selectivity level.
See third_party/fvsb_hnswlib/README.md
for advanced configuration.
This section covers how to set up the modified PostgreSQL environment, prepare data, index it, and run benchmarks.
We provide a script to automate the build and setup of PostgreSQL with our custom pgvector extension.
-
Navigate to the
builddirectory:cd build -
Run the setup script:
./setup_pg_env.sh
What this does:
- Downloads and compiles PostgreSQL (v14.10) to
$HOME/fvsb_pg_build/postgres. - Clones
pgvectorand replaces HNSW source files with our custom implementation fromfvsb_pgvector/. - Installs the custom
pgvectorextension. - Initializes a database cluster at
$HOME/fvsb_pg_build/data. - Starts the PostgreSQL server.
- Creates a superuser
vecbenchand databasevecbench.
- Downloads and compiles PostgreSQL (v14.10) to
-
Important: Source the environment variables to add
psqlandpg_ctlto your PATH:source $HOME/fvsb_pg_build/env.sh
Before running benchmarks, you must download and preprocess the datasets (e.g., converting to HDF5/fvecs, generating ground truth, and creating selectivity bitmaps).
-
Download and Preprocess Datasets: From the root directory, run:
python3 -m gen_workloads.prep_ds
Note: You can modify
DS_TO_PREPingen_workloads/prep_ds.pyto specify which datasets to download (e.g.,openai5M,sift10M). -
Generate Bitmaps: Generate bitmaps for different selectivity levels:
python3 -m gen_workloads.gen_bitmaps
This step creates the table, inserts vectors, builds the HNSW/ACORN index, and generates TID mappings.
Run the indexing script:
python3 benchmarks/db_table_indexing_parallel.py --workload <workload_name><workload_name>: Matches the keys inconf.json(e.g.,openai5M,sift10M,cohere10M).
Example:
python3 benchmarks/db_table_indexing_parallel.py --workload openai5MThis step executes the search queries with various filtering strategies (ACORN, Inline Filtering, etc.).
Run the benchmark script:
python3 benchmarks/db_benchmark_parallel.py --workload <workload_name> --k <k> --verboseExample:
python3 benchmarks/db_benchmark_parallel.py --workload openai5M --k 10 --verbose- Results will be saved in
vecbench_results/. - Logs are written to
/tmp/fvsb_pg_logs/.
fvs/
├── README.md # This file
├── build/
│ ├── setup_hnswlib_env.sh # Build script for C++ benchmarks
│ └── setup_pg_env.sh # Build script for PostgreSQL
├── gen_workloads/ # Dataset preparation & bitmap generation
│ ├── README.md # Detailed workload generation docs
│ ├── convert_fvecs_to_hdf5.py # Convert fvecs → HDF5
│ ├── prep_ds.py # Download & preprocess HDF5 datasets
│ ├── gen_bitmaps.py # Generate selectivity bitmaps
│ ├── load_data.h # C++ HDF5/bitmap loading utilities
│ └── conf.json # Dataset configuration
├── third_party/
│ ├── fvsb_hnswlib/ # C++ HNSW/ACORN implementations
│ │ ├── README.md # Detailed HNSWLib docs
│ │ ├── acorn/acornalg.h # ACORN algorithm
│ │ ├── hnsw/hnswalg.h # Modified HNSW
│ │ ├── indices_tests/ # C++ test programs
│ │ └── experiment/ # Benchmark runner
│ └── fvsb_pgvector/ # Custom pgvector extension
└── benchmarks/ # PostgreSQL benchmark scripts