Back to search

University of British Columbia

Workload-aware SQL query recommendation using retrieval-augmented generation

Abstract

dc:description

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.

Degree

thesis:*
Name thesis:degree_name
Master of Science - MSc
Level thesis:degree_level
master's
Discipline thesis:degree_discipline
Computer Science
Grantor dc:publisher
University of British Columbia
Year dc:date
2025

Author and committee

dc:creator, dc:contributor.*
Author dc:creator
  • Soltan Aghai, Ehsan
Contributors dc:contributor
  • Pottinger, Rachel

Rights

dc:rights
Statement dc:rights
  • Attribution-NonCommercial-NoDerivatives 4.0 International
Language dc:language
eng

Identifiers

dc:identifier.*
Handle dc:identifier
http://hdl.handle.net/2429/90790

Chain of custody

source
Harvested from
University of British Columbia
Base URL
circle.library.ubc.ca/oai/request
Last updated
2026-11-19
Source record
OAI-PMH GetRecord
related terms
citation

Soltan Aghai, Ehsan. Workload-aware SQL query recommendation using retrieval-augmented generation. master's thesis, University of British Columbia, 2025. http://hdl.handle.net/2429/90790