This page provides a detailed reference for the tuning parameters available for Scalable Nearest Neighbors (ScaNN) indexes in AlloyDB for PostgreSQL.
For a step-by-step tutorial on how to implement vector search from start to finish, see the guide on how to Perform a vector search .
Tuning parameters
The following index and query parameters are used to find the right balance of recall and queries per second (QPS).
mode
-
AUTO: automatically-tuned index -
MANUAL: manually-tuned index
For more information, see Create a ScaNN index .
Index creation
(optional)
max_num_levels
The available values are as follows:
-
1: Two-level ScaNN index -
2: Three-level ScaNN index -
3: Four-level ScaNN index
Index creation
(optional)
num_leaves
30000000
. For more information on choosing this value, see Tune a ScaNN index
and Best practices for tuning ScaNN indexes in AlloyDB
.Index creation
(required for manually-tuned indexes)
quantizer
SQ8
which provides better query performance with minimal recall loss (typically less than 1-2%).Set it to
FLAT
if a recall of 99% or higher is required.(optional)
scann.enable_pca
Set to
false
if you observe deterioration in recall.(optional)
auto_maintenance
Index creation
(optional)
scann.pct_leaves_to_search
scann.num_leaves_to_search
Absolute number of partitions to search. This lets you trade off between
query recall and QPS. The default value is 1% of num_leaves
.
Higher values result in better query recall, but lower QPS. Similarly, lower values result in worse query recall, but better QPS.
Query runtime
(optional)
scann.pre_reordering_num_neighbors
Specifies the number of candidate neighbors to consider during the reordering stages once the initial search identifies a set of candidates. Set this parameter to a value higher than the number of neighbors you want the query to return. Higher values result in better recall, but lower QPS.
The default is 0
, which disables reordering. If PCA is
enabled during index creation, the default is 50 x K
, where K
is the LIMIT specified in the query.
Query runtime
(optional)
scann.num_search_threads
2
.(optional)
scann.satisfy_limit
( Preview
)
relaxed_order
, the database flag addresses insufficient recall. Insufficient recall can occur when a query's observed recall falls below the target recall, which is more likely when using filters. This setting helps achieve the target recall by allowing the vector scan to continue searching beyond the num_leaves_to_search
limit until a sufficient number of results are found.(optional)
scann.max_pct_leaves_to_search
( Preview
)
scann.satisfy_limit
enabled. This is the only upper bound GUC available and applies to both auto and manual search modes. It prevents the search from overshooting, which might significantly degrade performance. This is applicable when scann.satisfy_limit
is turned on.You can set this parameter to any value between
0
to 100
. The default value is 15%
. This default value is based on the rationale that if a search needs to examine more than 15% of the leaves, the filter is likely selective enough that approximate nearest neighbor (ANN) search doesn't provide a benefit, making pre-filtering k-nearest neighbor (KNN) a more suitable choice.(optional)

