arXiv:2606.07923cs.DBcs.AI2026-06被引 1

用AI优化语义查询,让大模型数据库更快更省算力。

Larch: Learned Query Optimization for Semantic Predicates

论文配图:Larch: Learned Query Optimization for Semantic Predicates
图 1 · 摘自论文原文
  • 用图神经网络建模语义过滤器,自动规划执行顺序。
  • 实测比现有方法节省3到19倍的token开销。
  • 适合处理含文本/图像等非结构化数据的AI SQL任务。

随着大语言模型(LLMs)的发展,许多数据库系统引入了语义操作符,实现对非结构化数据(如文本、图像、视频)的分析型查询。然而,语义操作符通常带来高推理成本和延迟,使大规模数据上的语义(AI)SQL查询难以应用;同时,其语义特性导致数据库引擎将其视为黑盒,难以优化。本文提出Larch框架,用于优化AI SQL查询中语义过滤器的执行。灵感来自两点:一是语义操作符的高延迟为计算密集型运行时优化技术提供了空间;二是非结构化数据常伴随嵌入表示,支持高效语义比较。基于此,我们提出两个变体:Larch-A2C使用嵌入增强的门控图神经网络编码任意语义过滤器表达式树,并将评估顺序建模为马尔可夫决策过程;Larch-Sel则通过监督学习预测过滤器选择性,再用动态规划为每行输入寻找近似最优评估顺序。在多样真实数据集与综合合成工作负载上评估,两种变体均显著优于现有优化技术,在token使用量上表现更优。结果表明,Larch在多种工作负载下均具鲁棒性,相比Palimpzest和Quest,总token成本降低3至19倍。

原文摘要 · Abstract (English)

With the advent of Large Language Models (LLMs), many database systems introduced semantic operators that enabled analytical queries over unstructured data (e.g. text, images, videos). Semantic operators typically incur high inference costs and latencies making semantic (AI) SQL queries challenging to apply on large scale datasets. At the same time, their semantic nature leads database engines to treat them as black boxes, making AISQL queries difficult to optimize. In this paper, we introduce Larch, a framework for optimizing the execution of semantic filters in AI SQL queries. Larch was inspired by two key observations: i) the high latency of semantic operators leaves significant room for computationally-heavy runtime optimization techniques, ii) unstructured data are typically accompanied by semantic information in the form of embeddings allowing for efficient semantic comparisons between AI_FILTER prompts and data values. Based on these two key observations, we present two Larch variants: Larch-A2C and Larch-Sel. Larch-A2C encodes arbitrary semantic filters expression tree using an embedding-augmented Gated Graph Neural Network and formulates the filter evaluation order as a Markov decision process. In contrast, Larch-Sel leverages a supervised learning model to predict filter selectivities, subsequently applying dynamic programming to find a near-optimal evaluation order for each input row. Evaluated across diverse real-world datasets and comprehensive synthetic workloads, both Larch variants always outperform existing semantic filter optimization techniques in terms of token usage. Our results demonstrate that Larch is robust across diverse workloads, reducing total token cost overhead by 3x-19x compared to Palimpzest and Quest.

语义查询AI SQL优化框架大模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。