
Supercharge pgvector: 4x Faster HNSW with AlloyDB

AlloyDB is a PostgreSQL-compatible database with a built-in columnar engine that can accelerate pgvector HNSW vector search. Standard PostgreSQL HNSW, even when fully cached in shared buffers, still pays overhead from buffer manager operations like page pinning, lock acquisition, and LRU management. AlloyDB‘s columnar engine bypasses this overhead by pinning the HNSW index directly into its own memory, using a vectorized layout for pointer-heavy graph traversals, and operating outside the PostgreSQL buffer manager entirely.
Benchmarks on the GloVe 100 Angular dataset (1M+ records, limit 100) on a C4A 16vCPU instance show two benefits. At a fixed recall of 0.95, queries per second (QPS) increase by 4.2x to 4.9x. At a fixed QPS of ~350, recall jumps from approximately 0.78 to over 0.94—a 0.163 gain. These improvements come purely from memory architecture, not from moving data from disk to RAM.
Enabling the feature requires setting two flags (google_columnar_engine.enabled and google_columnar_engine.enable_index_caching) and then adding an existing HNSW index to the columnar engine with a simple SQL command. The article notes that the columnar engine also supports ScaNN indexes from Google Research, and standard KNN search remains available for 100% recall. No application code changes are needed since the acceleration works transparently with standard pgvector SQL syntax.


