Activate adaptive filtering in AlloyDB for PostgreSQL
Stay organized with collections
Save and categorize content based on your preferences.
This page describes adaptive filtering in AlloyDB.
Adaptive filtering analyzes query patterns and data distributions during query execution to dynamically choose the most efficient filtering strategy such as inline or pre-filtering.
The AlloyDB query optimizer uses cost-based analysis to determine whether inline filtering or pre-filtering provides the best performance at any given point during query execution.
Such optimization is beneficial for AlloyDB's filtered vector searches, where adaptive filtering automatically switches between vector and metadata index usage to ensure efficient and accurate results without your manual intervention.
When adaptive filtering triggers a switch from inline filtering to pre-filtering during execution, the query plan dynamically changes.
For example, the plan can show Bitmap assisted pre-filtering in the Execution Strategy field when the optimizer determines that pre-filtering is more efficient at that point in the query. This dynamic change occurs as the system adapts to the actual data that it encounters during the query's execution.
[[["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-26 UTC."],[],[],null,["# Activate adaptive filtering in AlloyDB for PostgreSQL\n\n| **Preview**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| You can process personal data for this feature as outlined in the\n| [Cloud Data Processing\n| Addendum](/terms/data-processing-addendum), subject to the obligations and restrictions described in the agreement under\n| which you access Google Cloud.\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nThis page describes adaptive filtering in AlloyDB.\n| **Note:** Inline filtering is supported only when you use the ScaNN algorithm. Inline filtering is not compatible with the Inverted File (IVF), Inverted File Flat (IVFFlat), or Hierarchical Navigable Small Worlds (HNSW) algorithms.\n\nAdaptive filtering analyzes query patterns and data distributions during query execution to dynamically choose the most efficient filtering strategy such as inline or pre-filtering.\n\nThe AlloyDB query optimizer uses cost-based analysis to determine whether inline filtering or pre-filtering provides the best performance at any given point during query execution.\n\nSuch optimization is beneficial for AlloyDB's filtered vector searches, where adaptive filtering automatically switches between vector and metadata index usage to ensure efficient and accurate results without your manual intervention.\n\nEnable adaptive filtering\n-------------------------\n\nTo enable adaptive filtering, use the [`scann.enable_preview_features`](/alloydb/docs/reference/alloydb-flags#scann.enable_preview_features) flag.\n\nWhen adaptive filtering triggers a switch from inline filtering to pre-filtering during execution, the query plan dynamically changes.\n\nFor example, the plan can show `Bitmap assisted pre-filtering` in the **Execution Strategy** field when the optimizer determines that pre-filtering is more efficient at that point in the query. This dynamic change occurs as the system adapts to the actual data that it encounters during the query's execution. \n\n Limit (actual rows=10 loops=1)\n -\u003e Custom Scan (vector scan) on t1 (actual rows=10 loops=1)\n Execution Strategy: Bitmap assisted pre-filtering\n Order By: (vec_col \u003c=\u003e '[...]'::vector)\n Limit: 10\n Num Requalifications: 0\n Num filtered: 1000\n -\u003e Bitmap Index Scan on btree_idx (actual rows=10000 loops=1)\n Index Cond: (int_col \u003c= 100000000)\n\nWhat's next\n-----------\n\n- [Filtered vector search in AlloyDB](/alloydb/docs/ai/filtered-vector-search-overview)"]]