An in-depth analysis of AlloyDB’s vector search improvements
AlloyDB AI Uses Intelligent Adaptive Filtering to Improve Vector Search Performance
Google Cloud Next 2025: Today, Google Cloud revealed major improvements to AlloyDB AI’s ScaNN index, which are intended to boost search quality and performance for both structured and unstructured data. These developments, which were presented at Google Cloud Next 2025, respond to the growing demand for developers creating generative AI apps and AI agents to search several data types at once.
Vector search features have recently been added to contemporary relational databases, such as AlloyDB for PostgreSQL, to manage unstructured data. However, to achieve great performance and quality, rigorous optimization is needed when combining these vector searches with conventional SQL filters on structured data.
Filtered Vector Search challenges
Users can apply structured criteria to refine vector similarity searches with filtered vector search. Managing a product catalogue with over 100,000 items recorded in an AlloyDB table, for example, may need an online retailer to search for particular goods using both structured metadata (such as colour or size) and unstructured textual descriptions (such as “puffer jacket”). A standard query could resemble this:
SELECT * from the items WHERE text_embedding <-> ORDER BY color=’maroon’ ‘text-embedding-005’, ‘puffer jacket’, google_ml.embedding LIMIT OF 100
The second section of this example carries out a vector search on the text_embedding column, which has a vector index, while the colour column, which has a B-tree index, is subjected to the structured filter color=’maroon’.
The sequence in which the database conducts the vector search and the SQL filter has a significant impact on how efficient this query is. Optimizing this ordering according to workload characteristics is the responsibility of the AlloyDB query planner. The filter’s selectivity is a major determinant in this choice. The frequency with which a certain criterion occurs in the dataset is known as selectivity.
Optimizing with Pre-filtering, Post-filtering, and Inline Filtering
Filter selectivity is used by AlloyDB’s query planner to intelligently select various strategies:
- High Selectivity: The planner frequently uses a pre-filter when a filter is very selective, which means that only a small portion of data fulfils the requirements (for example, 0.2% of items are’maroon’). The computationally demanding vector search is performed after the filter (e.g., WHERE color=’maroon’) has been applied. This effectively reduces the candidate set (for example, from 100,000 to 200 products) using a B-tree index. Only this smaller set is then subjected to the vector search (also known as a K-Nearest Neighbours or KNN search), ensuring 100% recall in the filtered results.
- Low Selectivity: A pre-filter is ineffective if a filter has low selectivity (for example, 90% of products are “blue”) because it doesn’t considerably narrow down the search field. The planner employs a post-filter approach in these situations. First, an initial group of candidates (e.g., the top 100 based on vector similarity) is rapidly identified using an Approximate Nearest Neighbours (ANN) vector search that makes use of indexes such as ScaNN. Following the retrieval of these candidates, the filter condition (e.g., WHERE color=’blue’) is applied. Since many of the initial candidates are likely to meet the criteria, this method works well for filters with poor selectivity.
- Medium Selectivity: AlloyDB allows inline filtering, often known as in-filtering, for filters with medium selectivity (0.5–10% selectivity, like the colour “purple”). This approach combines the vector search with filter conditions. AlloyDB selects candidates that match the filter while simultaneously looking for approximate neighbours in a single pass by using a bitmap from a B-tree index. In contrast to pre-filtering, which narrows the search space, post-filtering on a highly selective filter does not run the danger of producing an excessively small number of results.
Adaptive filtering: Learning at Query Time
Workload characteristics and filter selectivities can fluctuate over time in complex real-world circumstances, which could cause the query planner to make inaccurate selectivity judgements based on out-of-date facts. This may lead to less-than-ideal execution strategies and lower-quality outcomes.
AlloyDB ScaNN offers adaptive filtration as a solution to this problem. This most recent development enables AlloyDB to use real observed statistics to determine the selectivity of filters at query time. The database can adjust its execution plan adaptively based on this real-time data, which results in a more ideal filter and vector search ordering. Cases of planner misestimations are considerably reduced by adaptive filtering.
Getting Started
As data changes, these improvements, which are driven by an intelligent database engine, strive to guarantee continually excellent and effective search results.
Adaptive filtering is now accessible in preview. With AlloyDB’s ScaNN index, users can begin vector search right now. There is a 30-day free trial instance of AlloyDB and $300 in free credits for new Google Cloud users.