🤖 AI Summary
Interactive SQL analysis suffers from high query latency and user wait times due to the requirement of complete SQL input before execution. Method: This paper proposes an LLM-driven speculative query execution framework featuring a dual-path speculation mechanism: (1) real-time parsing of incomplete SQL statements via an LLM to infer query structure and critical base tables; and (2) pre-compilation of execution plans and incremental materialization of lightweight temporary tables based on these inferences. The system supports streaming result rendering and interactive exploration guidance. Contribution/Results: This work introduces speculative execution to interactive SQL for the first time. Evaluated on real-world large-scale datasets, it achieves up to 289× end-to-end latency reduction and significantly shortens task completion time. A user study confirms improved schema exploration efficiency, with operational overhead limited to just $4/hour.
📝 Abstract
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 imes$ and kept the overhead reasonable, at $$4$ per hour.