structured query language

Writing and optimizing database queries using SQL involves composing SELECT/JOIN/GROUP BY/CTE statements, designing indexes and transactions for consistency, and working with RDBMSs like PostgreSQL, MySQL, or SQL Server plus tools for query planning and performance tuning.

structuredquerylanguage

12-Month Skill Trend

Momentum and market value over time
Trending
Score
+20 in 12 mo
96
12 mo agoNow
Career
Value
+$12K in 12 mo
$42K/year
12 mo agoNow

Recommended Survey Paper

Quick overview of the field
View more

Must-Read Papers

Most classic and influential ideas
View more

Towards Cross-Model Efficiency in SQL/PGQ

May 12, 2025
HR
Hadar Rotschield
🏛️ Hebrew University

SQL/PGQ standards enable hybrid relational and graph query processing, yet experiments reveal substantial performance disparities—even for semantically equivalent SQL and PGQ queries—due to syntax-driven, model-isolated optimization in existing systems, lacking cross-model synergy. This paper proposes the first holistic unified optimization framework that transcends syntactic boundaries between SQL and PGQ, instead leveraging query semantics and data characteristics to automatically select optimal execution strategies. Key technical innovations include: (i) cross-model query normalization via equivalence-aware analysis; (ii) cost-aware operator fusion; and (iii) adaptive execution plan generation. Experimental evaluation demonstrates that the framework significantly narrows performance gaps among functionally identical queries, achieving an average 3.2× speedup. It thus provides critical enabling technology for efficient, standardized SQL/PGQ deployment.

Need for holistic cross-model optimization approachPerformance gaps between SQL and graph query modelsSeparate optimizations for SQL and graph queries

Speeding up SQL subqueries via decoupling of non-correlated predicate (extended version)

Oct 07, 2025
DR
Dmitrii Radivonchik
🏛️ Independent | Saint-Petersburg University

To address the low execution efficiency of SQL correlated subqueries, this paper proposes a predicate separation optimization technique: predicates in the subquery that are independent of the outer query are precomputed and applied for early filtering, thereby significantly reducing the number of correlated subquery invocations. Building upon this rewrite, we design a novel execution architecture on a block-based Volcano model, integrating position-aware columnar storage with late materialization. Our core contribution is the first deep integration of predicate correlation analysis with storage- and execution-layer optimizations. Experimental evaluation on PosDB and PostgreSQL demonstrates up to 5× query speedup. Additionally, we introduce a lightweight cost model to accurately estimate the optimization benefits.

Enhancing query performance in column-stores using position-aware techniquesOptimizing correlated SQL subqueries through predicate decouplingReducing correlated predicate evaluations via non-correlated isolation

This work addresses the limitation of traditional database logical design, which overlooks the capacity of large language models (LLMs) to comprehend schema semantics, thereby constraining Text-to-SQL accuracy. For the first time, LLM-friendliness is incorporated into logical schema design through three semantic-preserving and composable transformation strategies: abstraction (+A), workload-aware partitioning (+P), and descriptive renaming (+R). The proposed approach is compatible with both supervised and zero-shot settings, yielding consistent improvements across multiple Text-to-SQL models. Evaluated on the BIRD-Union and Spider-Union benchmarks, the method achieves up to a 4.2% absolute gain in execution accuracy, significantly enhancing the mapping from natural language queries to executable SQL statements.

LLM-friendly schemalogical database designschema transformation

Conformance Testing of Relational DBMS Against SQL Specifications

Jun 13, 2024
SL
Shuang Liu
🏛️ Renmin University of China | Tianjin University | Singapore Management University | East China Normal University | University of Science and Technology of China

This work addresses the challenge of verifying relational database management systems’ (RDBMS) compliance with SQL semantics at the standard specification level. We present the first executable Prolog reference implementation grounded in the complete formal SQL semantics defined by ISO/IEC 9075, integrated with differential fuzz testing for semantic-level black-box validation. Unlike prior approaches relying solely on crash detection or meta-transformation, our method enables end-to-end verifiable modeling of SQL standard semantics. Empirical evaluation across MySQL, TiDB, SQLite, and DuckDB uncovered 19 previously unknown vulnerabilities and 11 semantic inconsistencies—each traceable to explicit violations, omissions, or ambiguities in the SQL standard. Our approach significantly enhances the decidability and interpretability of SQL implementation correctness.

Detecting bugs and inconsistencies in major RDBMS systemsFormally defining SQL semantics for reference implementationTesting RDBMS semantic conformance to SQL specifications

Exploring the Use of LLMs for SQL Equivalence Checking

Dec 07, 2024
RS
Rajat Singh
🏛️ Indian Institute of Technology Delhi

Automated equivalence checking for complex SQL queries—critical for database education and query optimizer debugging—lacks efficient, reliable solutions. Method: This work pioneers the systematic evaluation of large language models (LLMs) for high-accuracy SQL equivalence judgment without formal proofs. We propose a prompt engineering framework grounded in unoptimized logical query plans, integrating SQL parsing, multi-strategy prompting, synthetic data augmentation, and task-specific supervised fine-tuning to bridge the performance gap between smaller LLMs and GPT-class models. Contribution/Results: Our approach achieves ≈100% accuracy on equivalent SQL pairs and 70% on non-equivalent pairs, while generating human-readable step-by-step reasoning and concrete counterexamples. It extends support beyond restricted SQL subsets—unlike conventional methods—and establishes a practical, interpretable, LLM-driven paradigm for database education and system debugging.

Benchmark SQLEquiQuest tests real-world SQL complexityLLMs address SQL query equivalence checking limitationsLLMs show bias in non-equivalent SQL pair predictions

Latest Papers

What's happening recently
View more

This work addresses the challenges of Text-to-SQL in large analytical databases, where complex schemas, ambiguous parsing, and data-dependent decisions hinder performance, and conventional fixed-pipeline systems struggle to recover from early errors. To overcome these limitations, the authors propose FlexSQL, an agent-based framework that integrates dynamic schema retrieval and a flexible execution mechanism, enabling exploration of schema structures, data validation, and backtracking for correction at any reasoning stage. FlexSQL supports dual-level repair—both at the code and planning levels—and combines SQL/Python hybrid generation with multi-interpretation execution plans. Evaluated on the Spider2-Snow benchmark, this approach achieves 65.4% accuracy, outperforming stronger open-source baselines and delivering over a 10% performance gain when integrated into general-purpose programming agents.

ambiguous queriescomplex schemadatabase interaction

This work addresses the limitations of existing SQL rewriting approaches, which either rely on rigid rule-based systems lacking adaptability or depend on large language models (LLMs) that incur high computational costs and privacy concerns. To overcome the scarcity of high-quality domain-specific data for training small language models, the authors propose LASER, a novel framework that integrates Monte Carlo Tree Search (MCTS) with LLM-guided mutation to generate SQL-MCTS—a large-scale corpus of complex, slow queries. They further introduce SQL-GRPO, a group-relative policy optimization algorithm featuring anchored group advantages and a complexity-adaptive dynamic rollout mechanism. Experiments on the Qwen3 small model demonstrate that LASER achieves an exceptional trade-off among execution efficiency, zero-shot transfer capability, and inference overhead, significantly outperforming both rule-based systems and LLM-based alternatives.

database efficiencyquery optimizationSmall Language Models

Pi-SQL: Enhancing Text-to-SQL with Fine-Grained Guidance from Pivot Programming Languages

Jun 01, 2025
YC
Yongdong Chi
🏛️ Shanghai University of Finance and Economics | Tsinghua University | Beihang University | Wuhan University | Southern University of Science and Technology

To address the accuracy bottleneck in natural language-to-SQL generation caused by semantic gaps, this paper proposes a two-stage approach that leverages high-resource Python programs as an executable intermediary: first, a large language model generates fine-grained, executable Python code capturing precise operational logic; second, SQL queries are synthesized from this Python representation. This work introduces, for the first time, Python as a semantic alignment pivot between natural language and SQL, enabling execution-feedback-driven SQL re-ranking, reward-based validity scoring, and result-consistency verification. Evaluated across multiple benchmarks, our method achieves a 3.20-percentage-point improvement in execution accuracy over the strongest baseline and increases effective efficiency score by 4.55. It significantly enhances generalization to complex queries and improves reasoning efficiency.

Bridging semantic gap between natural language and SQLEnhancing SQL generation with Python pivotImproving accuracy of text-to-SQL conversion

This study investigates the necessity of large language models (LLMs) for natural language to SQL (NL2SQL) tasks and challenges the prevailing overestimation of SQL query complexity. Through empirical analysis of 376 real-world databases, the work reveals— for the first time—that SQL query templates follow a power-law-like distribution: merely 13% of distinct templates account for 70% of all queries. Leveraging large-scale database sampling, SQL template abstraction, frequency statistics, and natural language–SQL alignment techniques, the authors demonstrate that query complexity does not monotonically increase with the number of tables and that the majority of queries are highly predictable. These findings underscore the advantages of template-based approaches in terms of security, cost-efficiency, and auditability, thereby questioning the dominant paradigm that relies on complex LLMs for NL2SQL translation.

finitenessLLMsnatural language to SQL

Hot Scholars

DR

Dan Roth

Professor of Computer Science, University of Pennsylvania
Natural Language ProcessingMachine LearningKnowledge Representation and ReasoningArtificial Intelligence
VG

Vivek Gupta

Assistant Professor of Computer Science, Arizona State University
Artificial IntelligenceNatural Language ProcessingLarge Language ModelsInformation Retrieval
HU

Henning Urbat

Postdoctoral Researcher, Friedrich-Alexander-Universität Erlangen-Nürnberg
Theoretical Computer Science
YL

Yuyu Luo

Assistant Professor, HKUST(GZ) / HKUST
Data AgentsLLM AgentsDatabaseText-to-SQL
MZ

Martin Zimmermann

Aalborg University
computer scienceverificationautomata theorytemporal logics