JOURNAL ARTICLE

Workload-aware SQL query recommendation using retrieval-augmented generation

Abstract

Writing effective SQL queries remains a major obstacle for non-expert users who need to explore and analyze data. While recent advances in deep learning have enabled limited forms of SQL query recommendation, existing systems typically focus on predicting partial query structures or rely on schema-specific features. In this thesis, we present a retrieval-augmented generation (RAG) framework for recommending full SQL queries based solely on previous user queries in a session. At the core of our approach is a transition-aware dual encoder trained to retrieve the most likely next query template by capturing both semantic similarity and structural transitions across queries. This retrieval is followed by a language model that generates the full SQL query, conditioned on the retrieved template, recent query history. Our method requires no access to the database schema and adapts naturally to evolving workloads. Compared to traditional rule-based or collaborative recommendation systems, it offers a more flexible and interpretable solution that models user behavior over time. Empirical results show that our system produces contextually relevant queries, improving usability for users with limited SQL experience.

Keywords:
SQL Query by Example Query language Language Integrated Query Query expansion Query optimization Data definition language View Web query classification

Metrics

0
Cited By
0.00
FWCI (Field Weighted Citation Impact)
0
Refs
0.54
Citation Normalized Percentile
Is in top 1%
Is in top 10%

Topics

Advanced Database Systems and Queries
Physical Sciences →  Computer Science →  Computer Networks and Communications
Semantic Web and Ontologies
Physical Sciences →  Computer Science →  Artificial Intelligence
Information Retrieval and Search Behavior
Physical Sciences →  Computer Science →  Information Systems
© 2026 ScienceGate Book Chapters — All rights reserved.