Select a documentation version: <button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">16.3.0</button>

- [Current (18.4.0)](https://docs.cloud.google.com/alloydb/omni/kubernetes/current/docs/ai/scann-vector-query-perf-overview.md.txt)
- [18.4.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.4.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [18.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.3.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [18.1.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/18.1.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [17.10.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.10.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [17.9.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.9.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [17.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.7.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [17.5.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/17.5.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [16.14.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.14.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [16.13.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.13.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [16.11.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.11.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [16.9.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.9.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [16.8.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.8.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [16.3.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.18.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.18.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.17.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.17.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.15.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.15.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.13.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.13.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.12.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.12.0/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.7.1](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.1/docs/ai/scann-vector-query-perf-overview.md.txt)
- [15.7.0](https://docs.cloud.google.com/alloydb/omni/kubernetes/15.7.0/docs/ai/scann-vector-query-perf-overview.md.txt)

<br />

This page provides a conceptual overview of improving vector query performance using the AlloyDB AI Scalable Nearest Neighbor (ScaNN) index. For more information, see [Create a ScaNN index](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/ai/create-scann-index).

<br />

The ScaNN index uses tree-quantization-based indexing, in which indexes learn
a search tree together with a quantization (or hashing) function. When you run
a query, the search tree is used to prune the
search space, while quantization is used to compress the index size. This pruning
speeds up the scoring of the similarity---in other words, the distance---between
the query vector and the database vectors.

To achieve both a high query-per-second rate (QPS)
and a high recall with your nearest-neighbor queries, you must partition
the tree of your ScaNN index in a way that is most appropriate to your data
and your queries.

High-dimensional embedding models can retain much of the information at much
lower dimensionality. For example, you can retain 90% of the information with
only 20% of the embedding's dimensions. To help speed up such datasets,
the AlloyDB AI ScaNN index automatically performs dimension reduction
using [Principal Component Analysis](https://en.wikipedia.org/wiki/Principal_component_analysis)
(PCA) on the indexed vectors, which further reduces CPU and memory usage for
the vector search. For more information, see
[`scann.enable_pca`](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/reference/scann-index-reference.md.txt).

Because dimension reduction causes minor recall loss in the index, the
AlloyDB AI ScaNN index compensates for recall loss
by first performing a ranking
step with a larger number of PCAed vector candidates from the index. Then,
ScaNN re-ranks the PCAed vector candidates by the original vectors.
For more information, see [`scann.pre_reordering_num_neighbors`](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/reference/scann-index-reference.md.txt).

## What's next

- Learn [best practices for tuning ScaNN indexes](https://docs.cloud.google.com/alloydb/omni/kubernetes/16.3.0/docs/ai/best-practices-tuning-scann.md.txt).

- [Get started with vector embeddings using AlloyDB AI](https://codelabs.developers.google.com/alloydb-ai-embedding#0).

- Learn more about the [AlloyDB AI ScaNN index](https://cloud.google.com/blog/products/databases/understanding-the-scann-index-in-alloydb).