Training-Free Query Optimization via LLM-Based Plan Similarity

📅 2025-06-06
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
Traditional query optimizers rely on error-prone cost models, while learned optimizers require costly offline training and lack deployment flexibility. Method: We propose a training-free, LLM-embedding-driven execution plan optimization framework. It leverages pre-trained large language models to map SQL queries and their execution plans into a unified embedding space; retrieves semantically similar historical queries via k-nearest-neighbor search; recommends efficient hint sets through majority voting; and ensures robustness via lightweight consistency checking and full-plan-space fallback. Contribution/Results: This is the first work to employ LLM-derived execution plan embeddings for training-free query optimization. It enables end-to-end automatic hint recommendation and achieves deep integration with OpenGauss. Evaluated on the JOB-CEB benchmark, our approach reduces average query latency by 21%, significantly enhancing both practicality and deployment efficiency.

Technology Category

Application Category

📝 Abstract
Large language model (LLM) embeddings offer a promising new avenue for database query optimization. In this paper, we explore how pre-trained execution plan embeddings can guide SQL query execution without the need for additional model training. We introduce LLM-PM (LLM-based Plan Mapping), a framework that embeds the default execution plan of a query, finds its k nearest neighbors among previously executed plans, and recommends database hintsets based on neighborhood voting. A lightweight consistency check validates the selected hint, while a fallback mechanism searches the full hint space when needed. Evaluated on the JOB-CEB benchmark using OpenGauss, LLM-PM achieves an average speed-up of 21% query latency reduction. This work highlights the potential of LLM-powered embeddings to deliver practical improvements in query performance and opens new directions for training-free, embedding-based optimizer guidance systems.
Problem

Research questions and friction points this paper is trying to address.

Using LLM embeddings for query optimization without training
Finding similar execution plans to recommend database hints
Improving query latency via training-free optimizer guidance
Innovation

Methods, ideas, or system contributions that make the work stand out.

Uses LLM embeddings for query optimization
Recommends hints via nearest neighbor voting
Lightweight consistency check ensures hint validity
N
Nikita Vasilenko
Ershov Institute of Informatics Systems, Novosibirsk, Russia.
A
Alexander Demin
Ershov Institute of Informatics Systems, Novosibirsk, Russia.
V
Vladimir Boorlakov
Novosibirsk State Technical University, Novosibirsk, Russia.