用大模型提前猜用户要查什么,让查询结果几乎秒出。
Speculative Ad-hoc Querying
- 用大模型预测用户未打完的查询,提前编译计划并预算小临时表。
- 实测查询延迟最高降低289倍,每小时成本仅4美元。
- 适合需要快速探索数据的分析师,能实时展示推测结果助发现规律。
分析大规模数据集需要快速响应的查询执行,但直接在海量数据上运行SQL查询通常很慢。本文探讨是否可在用户输入尚未完成时就启动查询执行,使结果几乎即时呈现。我们提出SpeQL系统,利用大语言模型(LLMs)基于数据库模式、用户历史查询和当前不完整输入,预测可能的查询。由于精确预测不可行,SpeQL通过两种方式推测部分查询:1)预测查询结构以提前编译和规划;2)预先计算比原始数据库小得多的临时表,但仍包含回答最终查询所需全部信息。此外,SpeQL持续实时显示推测查询及子查询的结果,辅助探索性分析。用户研究显示,SpeQL提升了任务完成速度,参与者认为其推测结果显示有助于更快发现数据模式。实验中,系统将用户查询延迟最高降低289倍,且每小时开销仅为4美元。
原文摘要 · Abstract (English)
Analyzing large datasets requires responsive query execution, but executing SQL queries on massive datasets can be slow. This paper explores whether query execution can begin even before the user has finished typing, allowing results to appear almost instantly. We propose SpeQL, a system that leverages Large Language Models (LLMs) to predict likely queries based on the database schema, the user's past queries, and their incomplete query. Since exact query prediction is infeasible, SpeQL speculates on partial queries in two ways: 1) it predicts the query structure to compile and plan queries in advance, and 2) it precomputes smaller temporary tables that are much smaller than the original database, but are still predicted to contain all information necessary to answer the user's final query. Additionally, SpeQL continuously displays results for speculated queries and subqueries in real time, aiding exploratory analysis. A utility/user study showed that SpeQL improved task completion time, and participants reported that its speculative display of results helped them discover patterns in the data more quickly. In the study, SpeQL improves user's query latency by up to $289\times$ and kept the overhead reasonable, at $\$4$ per hour.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。