Zhu Tianyou, Qi Yaru, Jiang Kongchen, Sang Yanting, and Yang Chao
State Grid Information & Telecommunication center (Big Data center), Beijing 100052, P. R. China
Received: October 13, 2025
Accepted: November 16, 2025
Publication Date: March 8, 2026
Schematic Diagram of the SLQ Framework.
Copyright The Author(s). This is an open access article distributed under the terms of the Creative Commons Attribution License (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are cited.
Download Citation: RIS | BibTeX | http://dx.doi.org/10.6180/jase.202607_30.025
In real-world database applications, SQL statements written by users often create performance bottlenecks because they violate best-practice rules. Traditional rule-based detectors have limited ability to recognize diverse and increasingly irregular statements and are costly to maintain. To address this, we propose SLQ, a two-stage intelligent SQL optimization framework. First, a lightweight stacked-LSTM module pinpoints problematic statements; then a pre-trained large language model, Qwen3, automatically generates explanations for each flaw and offers targeted rewrite suggestions, helping users quickly improve query quality. Evaluated on a standard dataset, SLQ achieves accuracy, precision, recall and F1 of 0.9841, 0.9974, 0.9702 and 0.9836 respectively, demonstrating superior detection and optimization capability and markedly enhancing SQL compliance and execution efficiency.
Keywords: SQL Query Optimization; Large Language Model (LLM); Long Short-Term Memory(LSTM)
- [1] J. Yuanli, (2005) “Optimization Methods for Database SQL Query Statements” Ordnance Automation 24(6): 113–114. DOI: 10.3969/j.issn.1006-1576.2005.06.055.
- [2] L. Jiajun and G. Mei, (2022) “Research and Application of Oracle Query Optimization” Information Technology and Informatization (1): 57–60. DOI: 10.3969/j.issn.1672-9528.2022.01.016.
- [3] Z. Zheng, X. Yukun, J. Chao, et al., (2024) “Research on Anomaly Detection in Electric Energy Metering Based on Improved Random Forest Algorithm” Electric Measurement and Instrumentation: 1–8.
- [4] L. Wei, C. Dongsheng, F. Fuyong, et al., (2024) “Research on Short-Term Power Load Forecasting Based on DCT-CNN-GRU” Electric Measurement and Instrumentation: 1–11.
- [5] S. Jinwei, L. Junni, X. Donghai, et al., (2024) “Research on Big Data Diagnosis Method for Transformer Condition Abnormality Based on Improved k-medoids Clustering and Carbon Constraint” Electrical Measurement and Instrumentation: 1–10.
- [6] H. Dan, Z. Yonggang, L. Shanhua, et al., (2024) “Calculation and Analysis of Theoretical Line Losses in LowVoltage Substations Based on AdaBoost Ensemble Learning Algorithm” Electrical Measurement and Instrumentation: 1–9.
- [7] S. Maesaroh, H. Gunawan, A. Lestari, et al., (2022) “Query optimization in mysql database using index” International Journal of Cyber and IT Service Management 2(2): 104–110.
- [8] S. Palanisamy and P. SuvithaVani. “A survey on RDBMS and NoSQL Databases MySQL vs MongoDB”. In: 2020 international conference on computer communication and informatics (ICCCI). IEEE, 2020, 1–7.
- [9] M. Malekpour, N. Shaheen, F. Khomh, et al., (2024) “Towards optimizing sql generation via llm routing” arXiv preprint arXiv:2411.04319:
- [10] M. M. Rahman, S. Islam, M. Kamruzzaman, et al., (2024) “Advanced query optimization in SQL databases for real-time big data analytics” Academic Journal on Business Administration, Innovation & Sustainability 4(3): 1–14.
- [11] Y. Du, Z. Cai, and Z. Ding, (2024) “Query Optimization in Distributed Database Based on Improved Artificial Bee Colony Algorithm” Applied Sciences 14(2): 846.
- [12] A. Uzzaman, M. M. I. Jim, N. Nishat, et al., (2024) “Optimizing SQL databases for big data workloads: techniques and best practices” Academic Journal on Business Administration, Innovation & Sustainability 4(3): 15–29.
- [13] V. B. Ramu, (2023) “Optimizing database performance: Strategies for efficient query execution and resource utilization” International Journal of Computer Trends and Technology 71(7): 15–21.
- [14] J. Shao, X. Liu, Y. Li, et al., (2015) “Database performance optimization for SQL Server based on hierarchical queuing network model” International Journal of Database Theory and Application 8(1): 187–196.
- [15] K. S. Maabreh. “Optimizing Database Query Performance Using Table Partitioning Techniques”. In: 2018 International Arab Conference on Information Technology (ACIT). IEEE, 2018, 1–4.
- [16] J. Zhang. “Research on database application performance optimization method”. In: 2016 6th International Conference on Machinery, Materials, Environment, Biotechnology and Computer. Atlantis Press, 2016, 2236–2239.
- [17] V. K. Myalapalli, T. P. Totakura, and S. Geloth. “Augmenting database performance via SQL tuning”. In: 2015 International Conference on Energy Systems and Applications. IEEE, 2015, 13–18.
- [18] S. J. Kamatkar, A. Kamble, A. Viloria, et al. “Database performance tuning and query optimization”. In: International Conference on Data Mining and Big Data. Springer International Publishing, 2018, 3–11.
- [19] X. Sun, B. Jiang, and X. He. “Database query optimization based on distributed photovoltaic power generation”. In: 2018 2nd IEEE Advanced Information Management, Communicates, Electronic and Automation Control Conference (IMCEC). IEEE, 2018, 2382–2386.
- [20] C. Anneser, N. Tatbul, D. Cohen, et al., (2023) “Autosteer: Learned query optimization for any sql database” Proceedings of the VLDB Endowment 16(12): 3515–3527.
