SLQ: Lightweight-Detection & LLM-Generation SQL SelfOptimization Framework
Abstract
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.
Fields of Study & Subjects
Advanced Database Systems and Queries
Software Engineering Research
Natural Language Processing Techniques
Publication details
- Journal / source
- DOAJ (DOAJ: Directory of Open Access Journals)
- Publication date
- 1 February 2026
- Language
- EN