Can Large Language Models Be Query Optimizer for Relational Databases?
Not on the map. Why?
Abstract (arXiv)
Query optimization, which finds the optimized execution plan for a given query, is a complex planning and decision-making problem within the exponentially growing plan space in database management systems (DBMS). Traditional optimizers heavily rely on a certain cost model constructed by various heuristics and empirical tuning, probably leading to generating suboptimal plans. Recent developments of Large Language Models (LLMs) have demonstrated their potential in solving complex planning and decision-making problems, such as arithmetic and programmatic tasks. In this paper, we try to explore the potential of LLMs in handling query optimization and propose a tentative LLM-based query optimizer dubbed LLM-QO, established on PostgreSQL's execution engine. In LLM-QO, we formulate query optimization in an autoregressive fashion which directly generates the execution plan without explicit plan enumeration. To investigate the essential input of LLM-QO, we design a customized data recipe named QInstruct to collect the training data from various optimizers and serialize the database's meta data, queries and corresponding plans into a textual format. Based on QInstruct, we implement a two-stage fine-tuning pipeline, Query Instruction Tuning (QIT) and Query Direct Preference Optimization (QDPO), to empower the capability of general-purpose LLMs in handling query optimization. In our experiments, LLM-QO can generate valid and high-quality plans and consistently outperforms both traditional and learned optimizers on three query workloads. Our findings verify that LLMs can be derived as query optimizers where generalization, efficiency and adaptivity deserve further research efforts.
Key facts. Cited by 10 papers in the map (data through 7 Oct 2026). First posted on arXiv 8 Feb 2025.
Builds on
No reference list yet.
Built on by
Citing papers per year: 2025: 6; 2026: 4.
10 papers.
- 2025A Survey of Data Agents: Emerging Paradigm or Overstated Hype?cited by 30
- 2025ReasonMed: A 370K Multi-Agent Generated Dataset for Advancing Medical Reasoningcited by 26
- 2025LLM/Agent-as-Data-Analyst: A Surveycited by 15
- 2025QUITE: A Query Rewrite System Beyond Rules with LLM Agentscited by 6
- 2026Multi-Segment Attention: Enabling Efficient KV-Cache Management for Faster Large Language Model Servingcited by 2
- 2026GenDB: The Next Generation of Query Processing -- Synthesized, Not Engineeredcited by 1
- 2026From Natural Language to Executable Option Strategies via Large Language Modelscited by 1
- 2025Training-Free Query Optimization via LLM-Based Plan Similaritycited by 0
- 2025LLM4Hint: Leveraging Large Language Models for Hint Recommendation in Offline Query Optimizationcited by 0
- 2026Test-Time Optimization of Physical Query Plans with LLMscited by 0
- 2026Multi-Segment Attention: Enabling Efficient KV-Cache Management for Faster Large Language Model Serving1 Jun 2026
- 2026From Natural Language to Executable Option Strategies via Large Language Models17 Mar 2026
- 2026GenDB: The Next Generation of Query Processing -- Synthesized, Not Engineered2 Mar 2026
- 2026Test-Time Optimization of Physical Query Plans with LLMs11 Feb 2026
- 2025A Survey of Data Agents: Emerging Paradigm or Overstated Hype?27 Oct 2025
- 2025LLM/Agent-as-Data-Analyst: A Survey28 Sep 2025
- 2025LLM4Hint: Leveraging Large Language Models for Hint Recommendation in Offline Query Optimization4 Jul 2025
- 2025ReasonMed: A 370K Multi-Agent Generated Dataset for Advancing Medical Reasoning11 Jun 2025
- 2025QUITE: A Query Rewrite System Beyond Rules with LLM Agents9 Jun 2025
- 2025Training-Free Query Optimization via LLM-Based Plan Similarity6 Jun 2025