SLQ: Lightweight-Detection & LLM-Generation SQL SelfOptimization Framework

Tianyou Zhu, Qi Yaru, Jiang Kongchen, Sang Yanting, Yang Chao · DOAJ (DOAJ: Directory of Open Access Journals) · 2026

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.

Read the paper · More papers on PaperTik