Skip to content
Open access

SafeQL: Search-based Refinement for Safe and Efficient LLM-based Text-to-SQL

May 2026 · Proceedings of the VLDB Endowment · Vol 19, pp. 2210-2223 · 0 citations · 58 references
Computer Science

TL;DR

SafeQL is proposed, a search-based refinement paradigm that redefines the role of the DBMS as an active guide in the refinement process, and significantly improves execution accuracy and efficiency compared to regeneration-based methods.

Abstract

Large language models (LLMs) have advanced Text-to-SQL by enabling natural language interfaces to databases without task-specific fine-tuning. However, existing LLM-based systems remain unreliable, often generating SQL queries that are invalid under the database schema, referencing non-existent tables, attributes, functions, or values. Such errors persist because interactions with the database management system (DBMS) are typically limited to error messages, leaving it in a largely passive role during query refinement. This paper proposes SafeQL, a search-based refinement paradigm that redefines the role of the DBMS as an active guide in the refinement process. Instead of regenerating entire queries after execution failure, SafeQL interprets DBMS feedback to incrementally repair only the erroneous components. Each refinement step is formulated as a guided search within a safe query space , where candidate queries are progressively validated through DBMS execution, thereby converging to an executable query and preventing repeated regeneration of errors. Experiments on the Bird and Spider benchmarks show that SafeQL significantly improves execution accuracy and efficiency compared to regeneration-based methods.

Read PDF

Similar papers

ExpeSQL: An Efficient, Experience-Guided Decompositional Search Framework for Text-to-SQL

This work introduces ExpeSQL, a zero-shot, open-source–compatible, and efficient framework that combines divide-and-conquer reasoning, Best-of-N candidate selection, and self-critique with experience-guided refinement that establishes a new paradigm for deployable, self-improving Text-to-SQL systems in dynamic, real-world environments.

Unknown authors · 0 citations
Open access Jul 2026

Schema-Guided Prompt Strategies for Text-to-SQL over Relational Databases Using Local LLMs

It is suggested that structured prompt engineering provides a practical alternative to model fine-tuning for locally deployed LLMs, offering an effective balance between SQL generation accuracy, computational efficiency, and data privacy.

Nurjayanti Nurjayanti, A. Adiwijaya, A. Romadhony et al. · 0 citations
Preprint Aug 2026

ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Models

This work presents a training-free framework that formulates SQL correction as a plan-guided, tree-structured debugging process that mitigates error accumulation during iterative refinement and demonstrates the effectiveness and stability of the approach in real-world deployments.

Xinmei Huang, Jie Song, Peng Li et al. · 0 citations
Open access 2026

LLM-augmented query optimization: a hybrid framework for intelligent SQL performance tuning

LLM-QOpt++ is presented, a novel hybrid, confidence-aware query optimization framework that unifies traditional CBO estimation, machine learning–based cost prediction, and large language model (LLM) reasoning within a single adaptive pipeline.

Hanan Abed Alwally Abed Allah · 0 citations
Open access Jul 2026

Schema-Aware Query Translation and Tabular Reasoning for Enterprise Databases

Schema-Aware Query Translation and Tabular Reasoning for Enterprise Databases aka Inference-from-RDBMS is presented, an open-source framework designed for schema-aware query translation, dynamic context pruning, and execution-guided tabular inference over complex RDBMS structures.

Harshil Lodhiya · 0 citations

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.