Date of Award
5-2026
Degree Type
Creative Project
Degree Name
Master of Science (MS)
Department
Computer Science
Committee Chair(s)
Curtis Dyreson
Committee
Curtis Dyreson
Committee
Mario Harper
Committee
Vicki Allan
Abstract
Large Language Models (LLMs) such as ChatGPT have become ubiquitous tools for working professionals in the software industry. Many engineers are finding new ways to increase productivity by offloading tasks onto LLMs, while others are finding it difficult to trust code produced artificially, even after review. Taking a look at both perspectives, this study aims to compare a human’s ability to optimize SQL queries to that of an LLM and assess the experience using both methods.
Manual query optimization is a tedious task that relies heavily on statistics, heuristics, and good intuition. The SQL developer must search for the optimal query shape–meaning the query’s structural configuration–to reduce the data accessed and operations performed. For large queries referencing dozens of tables, finding significant improvements can take countless days, if even possible. LLMs, however, are often able to perform this task in minutes if not seconds when prompted well. The task for the human then lies in reviewing the results and validating that they are correct. There has been much work in the past decade to enhance NL2SQL (Natural Language to SQL) abilities, and this project tests one of many useful applications.
The primary goal of this study is to determine whether ChatGPT can meet or surpass human abilities when performing SQL query optimization tasks within a Posgres database based on quantitative metrics such as execution time and cost. It also aims to test different methods of prompting ChatGPT to best complete this task. Furthermore, it provides a unique perspective by a human SQL developer performing optimization tasks by hand versus the experience of engineering prompts and running the query optimization tasks through an LLM. The findings will contribute to a fast-growing body of research involving AI-assisted application development and could help inform methods of semi-automated query optimization.
Recommended Citation
Dennis, Hailey, "SQL Query Optimization - Human vs. ChatGPT" (2026). All Graduate Reports and Creative Projects, Fall 2023 to Present. 138.
https://digitalcommons.usu.edu/gradreports2023/138
Included in
Artificial Intelligence and Robotics Commons, Databases and Information Systems Commons, Software Engineering Commons
Copyright for this work is retained by the student. If you have any questions regarding the inclusion of this work in the Digital Commons, please email us at .