Loading article...
Loading article...
Stream/Area:
-
Subject:
-
Paper ID:
IJSREM68834
Volume:
10 |
11 |
Nov 2026
Pages:
1-6
Publication Frequency:
Monthly (12 issues per year)
License:International Journal of Scientific Research in Engineering and Management follows the Creative Commons Attribution 4.0 (CC BY 4.0) License, allowing free use and distribution with proper attribution.

Department of Master of Computer Application
JCEI’s Jaihind Institute of Management and Research, Vadgaon Sahani
Department of Master of Computer Application
JCEI’s Jaihind Institute of Management and Research, Vadgaon Sahani
Writing correct and efficient SQL queries requires the knowledge of the database schema and of the query engine’s behavior. Therefore, direct data access is usually limited to the database experts. Most current natural language to SQL approaches focus on the result correctness of the generated SQL queries and neglect the efficiency of the queries. In this paper, we propose a Python-based multi-agent system which combines query generation and query optimization. Our system consists of five cooperating agents: a schema linking agent, a planning agent, a generation agent, a validation agent, and an optimization agent. These agents communicate with each other using explicit intermediate artifacts and use the database’s feedback, such as the output of EXPLAIN statements and the measured execution time of the generated queries, in order to verify their work. The optimization agent uses sargability-restoring rewrite rules as well as an execution-validated index advisor. It only accepts a change if the result set of the query is unchanged and if, in case of index advice, the latency of the query is decreased. We evaluated our system on SQLite using a synthetic four-table e-commerce database with three scales (10,000 to 200,000 orders) and a benchmark of 56 in-scope questions with independently written gold SQL queries. For all 56 in-scope questions, the generated SQL queries were correct. For eight out-of-scope questions, the system refused six of them and silently mis-answered two. The optimized queries returned identical results to the unoptimized queries in all cases. For 50,000 orders, the full optimizer achieved a geometric mean speedup of 1.79x (95% bootstrap CI 1.44–2.26) and 1.89x for 200,000 orders. The mean latency of the largest scale was decreased from 184.6 ms to 153.6 ms. An ablation study shows that most of the gain is achieved by query rewriting (1.43x alone) and that index advice alone is unreliable (1.13x, with 18% of queries slowed down by more than 10%). Since the planner is rule-based and the data are synthetic, our results demonstrate the value of the generate-validate-optimize loop rather than the open-domain translation accuracy.
KEYWORDS
In this paper, we presented a Python multi-agent pipeline to generate SQL from natural language questions and then optimize it with verified rewrites and measured index advice. We correctly answered all 56 in-scope questions on a synthetic e-commerce workload, with no change to query result, and achieved a geometric mean speedup of 1.79 to 2.07 (depending on scale). Most of the speedup was from rewrite, and index advice was mainly useful in combination with it. We also showed the limitations: modest absolute latency improvement, worse performance on some families, and silent errors on out-of-scope questions. Future work includes the replacement of rule-based planner and generator with LLM-backed component and testing on public benchmarks with realistic databases. Extending the pipeline to other engines, e.g., PostgreSQL, MySQL. Using hypothetical indexes, cost estimates instead of repeated timing. Measurement of index storage and write overhead. Formal verification of rewrite rules. Abstention mechanism for detecting uncovered parts of question.
1. Agrawal, S., Chaudhuri, S., Kollár, L., Marathe, A., Narasayya, V., & Syamala, M. (2004). Database tuning advisor for Microsoft SQL Server 2005. Proceedings of the 30th International Conference on Very Large Data Bases (VLDB), 1110–1121. 2. Chaudhuri, S., & Narasayya, V. R. (1997). An efficient, cost-driven index selection tool for Microsoft SQL Server. Proceedings of the 23rd International Conference on Very Large Data Bases (VLDB), 146–155. 3. Chaudhuri, S. (1998). An overview of query optimization in relational systems. Proceedings of the 17th ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems (PODS), 34–43. 4. Efron, B., & Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman & Hall. 5. Fleming, P. J., & Wallace, J. J. (1986). How not to lie with statistics: The correct way to summarize benchmark results. Communications of the ACM, 29(3), 218–221. 6. Gao, D., Wang, H., Li, Y., Sun, X., Qian, Y., Ding, B., & Zhou, J. (2024). Text-to-SQL empowered by large language models: A benchmark evaluation. Proceedings of the VLDB Endowment, 17(5), 1132–1145. 7. Katsogiannis-Meimarakis, G., & Koutrika, G. (2023). A survey on deep learning approaches for text-to-SQL. The VLDB Journal, 32. https://doi.org/10.1007/s00778-022-00776-8 8. Kossmann, J., Halfpap, S., Jankrift, M., & Plattner, H. (2020). Magic mirror in my hand, which is the best in the land? An experimental evaluation of index selection algorithms. Proceedings of the VLDB Endowment, 13(12), 2382–2395. 9. Kraska, T., Beutel, A., Chi, E. H., Dean, J., & Polyzotis, N. (2018). The case for learned index structures. Proceedings of the ACM SIGMOD International Conference on Management of Data, 489–504. 10. Li, J., Hui, B., Qu, G., et al. (2023). Can LLM already serve as a database interface? A big bench for large-scale database grounded text-to-SQLs. Advances in Neural Information Processing Systems (NeurIPS), 36, Datasets and Benchmarks Track.
Publication Date
11/9/2026
Peer Review Type
Double-Blind Peer Review
Review Rounds: 2
Documents
Article Views
0
Total views since publication
PDF Downloads
2
Total downloads since publication
Geographic Reach
5
Digital Preservation: This article is permanently archived on Zenodo and complies with all data preservation standards across major indexing platforms.
Plagiarism Screening
This manuscript has been checked for plagiarism using TurnitinPlagiarismChecker software.
Conflict of Interest
The authors declare no conflict of interest related to this research work.
Funding Information
No funding information available for this research.
Related research in the same subject area
Loading similar articles...