Latest
Google’s AlloyDB ScaNN index now compresses vectors automatically to cut memory use
Image: Google Cloud

Google’s AlloyDB ScaNN index now compresses vectors automatically to cut memory use

Chat about this article with your favourite AI tool

Google Cloud has detailed how the ScaNN index in AlloyDB automatically compresses vector data during index creation, aiming to remove memory as a bottleneck for retrieval-augmented generation (RAG) and other vector search workloads running on PostgreSQL.

The company said the index combines dimensionality reduction with quantization, so teams don’t need to build a separate preprocessing pipeline or move to larger machines just to handle high-dimensional embeddings.

Google Cloud AlloyDB ScaNN index vector compression diagram
Image: Google Cloud

Why memory becomes the problem

Google Cloud argues that teams evaluating vector databases tend to focus on recall, precision and p99 latency, only to run into memory limits as datasets grow from millions to billions of embeddings.

Using 1,536-dimension float32 vectors as an example, the company calculated that 50 million vectors take roughly 286GB of raw data, and 1 billion vectors take about 5.59TB. Building an index on data of that size, it said, forces engineers to either over-provision memory or accept a sharp drop in performance.

A common workaround is to reduce or quantize embeddings in the application before loading them. Google Cloud said that approach means maintaining external logic, transforming query vectors at runtime and discarding full-precision embeddings, which adds complexity and loses data fidelity.

Google Cloud AlloyDB ScaNN index vector compression diagram
Image: Google Cloud

How the compression works

With AlloyDB, full-precision raw embeddings stay in the table and can still be used for exact re-ranking. The index itself stores a compact version, built using two techniques:

  • PCA dimensionality reduction: During index creation, AlloyDB evaluates Principal Component Analysis and picks a reduced dimension that keeps nearest-neighbor recall high. If no suitable dimension is found, it skips PCA.
  • SQ8 scalar quantization: Enabled by default, it stores each dimension as an 8-bit integer rather than a 32-bit float, cutting index vector size by a further 4x.

Google Cloud said its experiments show PCA typically reduces dimensions by 67% to 87%, though results vary with the dataset. In an illustrative case where PCA shrinks 1,536 dimensions to 256 and SQ8 is applied, each vector falls from 6,144 bytes to 256 bytes, a 24x reduction. On that basis, 50 million vectors would need about 11.92GB and 1 billion vectors about 238GB.

Scale and speed claims

Google Cloud also made several performance claims for the index. Using a hierarchical four-level tree architecture, it said the ScaNN index scales beyond 10 billion vectors, with latency of 51 ms or less at P95 and 95% recall.

Compared with standard PostgreSQL HNSW indexing, the company said AlloyDB’s ScaNN index delivers:

  • Up to 6x faster vector queries
  • 10x faster filtered vector search
  • 16x faster index creation
  • 4x lower memory usage

For teams that stick with pgvector HNSW, Google Cloud said AlloyDB’s built-in Columnar Engine can speed up vector queries by up to 4x.

The ScaNN index also pairs with AlloyDB’s native BM25 full-text indexing to support hybrid search, the company said.

Getting started

Developers can deploy the ScaNN index by following the AlloyDB quickstart guide to set up an instance. Google Cloud said new users can also try AlloyDB through a 30-day free trial.

Google Cloud framed the update as a way to move from prototype-grade indexing to production database infrastructure for enterprise AI, with similarity search over up to 10 billion vectors running inside managed PostgreSQL.

Source: Google Cloud Blog