Activate adaptive filtering in AlloyDB for PostgreSQL

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.

Enable adaptive filtering

To enable adaptive filtering, use the scann.enable_preview_features flag.

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.

Limit (actual rows=10 loops=1)
  ->  Custom Scan (vector scan) on t1 (actual rows=10 loops=1)
        Execution Strategy: Bitmap assisted pre-filtering
        Order By: (vec_col <=> '[...]'::vector)
        Limit: 10
        Num Requalifications: 0
        Num filtered: 1000
        ->  Bitmap Index Scan on btree_idx (actual rows=10000 loops=1)
              Index Cond: (int_col <= 100000000)

What's next