NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

100x Cost & Latency Reduction: Performance Analysis of AI Query Approximation using Lightweight Proxy Models

Yeounoh Chung, Rushabh Desai, Jian He, Yu Xiao, Thibaud Hottelier, Yves-Laurent Kom Samo, Pushkar Kadilkar, Xianshun Chen, Sam Idicula, Fatma Özcan, Alon Halevy, Yannis Papakonstantinou · DOI

Abstract

Several data warehouse and database providers have recently introduced extensions to SQL called AI Queries, enabling users to specify functions and conditions in SQL that are evaluated by Large Language Models (LLMs). While powerful, these queries can become prohibitively costly when invoked thousands of times. This paper evaluates an AI query approximation approach that delivers >100x cost and latency reduction for semantic filters ($AI.IF$) and ranking ($AI.RANK$) by utilizing cheap, accurate proxy models over embedding vectors. We show that these proxy models preserve or even improve accuracy across various benchmarks, including a 10M-row Amazon reviews dataset.

The Challenge of AI Queries

Modern data platforms like Google BigQuery and Snowflake now support "AI Queries," allowing users to integrate LLMs directly into SQL for semantic filtering (AI.IF) or ranking (AI.RANK). For instance, a query might filter millions of customer support transcripts for specific sentiment or resolve complex natural language conditions.

However, LLM inference is computationally expensive and slow. Running an LLM on every row of a massive table is economically unfeasible for analytical workloads (OLAP) and too slow for interactive applications (HTAP). Existing optimizations like model cascading or row skipping often fail to reach the scale required for million-row datasets without significant accuracy loss.

Methodology: Lightweight Proxy Models

The proposed solution replaces expensive LLM calls with lightweight "proxy" models—specifically Logistic Regression (LR) trained on-the-fly. The system follows an automated workflow integrated into the database engine:

  1. Sampling & Labeling: The system selects a small representative subset of data. The LLM (e.g., Gemini) is called only to label this small sample, establishing a "ground truth."
  2. Embedding Generation: Unstructured text is converted into embedding vectors using models like Gecko.
  3. Proxy Training: A simple LR model is trained on these embeddings using the LLM-provided labels.
  4. Adaptive Selection: The system evaluates the proxy's accuracy. If it meets a quality threshold, it processes the remaining rows; otherwise, it falls back to the LLM.
System architecture for AI query approximation featuring the AI.IF and AI.RANK execution strategies.

The authors implemented this in two environments: Google BigQuery for online ad-hoc queries and AlloyDB for low-latency HTAP applications using offline pre-trained proxies.

Key Insights

  • Accuracy through Regularization: Simple Logistic Regression often outperforms the LLM because it acts as a regularizer, smoothing out noise or inconsistencies in raw LLM outputs.
  • Embedding Quality Over Hyperparameters: The choice of embedding model (e.g., Gecko vs. Gemma) significantly impacts performance more than fine-tuning the proxy model itself, allowing for a robust "one-size-fits-all" configuration.
  • Handling Imbalance: Weighted training techniques ensure proxies remain accurate even when target classes are rare.

Performance Results

The evaluation across diverse benchmarks (Amazon Reviews, IMDB, TREC-COVID) demonstrates massive efficiency gains without sacrificing quality.

Latency and cost improvements for Online and Offline Proxy Models compared to baseline LLM execution.

On a 10-million row table, the Online Proxy Model achieved a 329x latency improvement and 728x cost savings. The Offline version, suitable for transactional databases, reached a 991x latency improvement. Crucially, accuracy remained high; for example, on the Amazon Reviews 10k dataset, the proxy improved the F1-score from 0.739 (LLM) to 0.860.

Conclusion and Future Work

Lightweight proxy models offer a transformative path for scaling AI queries in databases. While they struggle with reasoning-heavy tasks like the HellaSwag benchmark, they provide order-of-magnitude improvements for most semantic filtering and ranking tasks. Future work includes integrating more diverse "cheap" models, such as cross-attention re-rankers, to handle complex ranking and semantic join operations.

Summary updated

BibTeX
@article{chung2026x,
  author = {Yeounoh Chung and Rushabh Desai and Jian He and Yu Xiao and Thibaud Hottelier and Yves-Laurent Kom Samo and Pushkar Kadilkar and Xianshun Chen and Sam Idicula and Fatma Özcan and Alon Halevy and Yannis Papakonstantinou},
  title = {{100x Cost \& Latency Reduction: Performance Analysis of AI Query Approximation using Lightweight Proxy Models}},
  journal = {Proc. ACM Manag. Data},
  year = {2026},
  doi = {10.1145/3802002},
}
Figure