ScaNN index uses tree-quantization based indexing. In Tree-quantization
techniques, 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 (i.e., 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.
A common characteristic of the current generation of high-dimensional embedding models is they can still retain much of the information at much lower dimensionality, for example 90% of the information can be retained with only 20% of the embedding's dimensions. To help speed up such datasets, AlloyDB ScaNN will automatically perform dimension reduction using Principal Component Analysis (see scann.enable_pca below) on the indexed vectors which further reduces cpu & memory usage for the vector search. Because dimension reduction still causes minor recall loss in the index, AlloyDB ScaNN compensates through an initial ranking step with a larger number of PCA'ed vector candidates from the index then re-ranking them by the original vectors (see scann.pre_reordering_num_neighbors).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[],null,["# ScaNN vector query performance overview\n\nSelect a documentation version: 15.12.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/ai/scann-vector-query-perf-overview)\n- [16.8.0](/alloydb/omni/16.8.0/docs/ai/scann-vector-query-perf-overview)\n- [16.3.0](/alloydb/omni/16.3.0/docs/ai/scann-vector-query-perf-overview)\n- [15.12.0](/alloydb/omni/15.12.0/docs/ai/scann-vector-query-perf-overview)\n- [15.7.1](/alloydb/omni/15.7.1/docs/ai/scann-vector-query-perf-overview)\n- [15.7.0](/alloydb/omni/15.7.0/docs/ai/scann-vector-query-perf-overview)\n\n\u003cbr /\u003e\n\nThis page gives a conceptual overview of improving vector query performance with the ScaNN Index.\n\n\u003cbr /\u003e\n\nScaNN index uses tree-quantization based indexing. In Tree-quantization\ntechniques, indexes learn a search tree together with a quantization (or\nhashing) function. When you run a query, the search tree is used to prune the\nsearch space while quantization is used to compress the index size. This pruning\nspeeds up the scoring of the similarity (i.e., distance) between the query vector\nand the database vectors.\n\nTo achieve both a high query-per-second rate (QPS)\nand a high recall with your nearest-neighbor queries, you must partition\nthe tree of your `ScaNN` index in a way that is most appropriate to your data\nand your queries.\n\nA common characteristic of the current generation of high-dimensional embedding models is they can still retain much of the information at much lower dimensionality, for example 90% of the information can be retained with only 20% of the embedding's dimensions. To help speed up such datasets, AlloyDB ScaNN will automatically perform dimension reduction using Principal Component Analysis (see `scann.enable_pca` below) on the indexed vectors which further reduces cpu \\& memory usage for the vector search. Because dimension reduction still causes minor recall loss in the index, AlloyDB ScaNN compensates through an initial ranking step with a larger number of PCA'ed vector candidates from the index then re-ranking them by the original vectors (see `scann.pre_reordering_num_neighbors`).\n\nWhat's next\n-----------\n\n- [Get started with vector embeddings using AlloyDB AI](https://codelabs.developers.google.com/alloydb-ai-embedding#0)."]]