Published 2025-05-30
How to Cite

This work is licensed under a Creative Commons Attribution 4.0 International License.
Abstract
This paper addresses the performance risk that may arise during the execution of structured query statements. It proposes a graph neural network-based method for SQL query risk classification. The method parses each query into a structured graph representation. A structure-semantics fusion module is used to jointly model operator types and structural dependencies of nodes. This enhances the model's ability to capture query semantics and execution paths. A risk-aware contrastive learning mechanism is also introduced. By constructing positive and negative risk sample pairs, the model improves the clustering and separation of query representations in the discriminative space. This further strengthens its capability in risk identification. Systematic experiments are conducted on several structured query datasets, including JOB, TPC-H, and IMDB. The results show that the proposed method outperforms various existing approaches in terms of accuracy, macro-average F1 score, precision, and recall. It demonstrates clear performance advantages. In addition, ablation studies verify the contribution of each module to overall performance. Transfer experiments also confirm the model's strong generalization ability across different query scenarios. This work provides an efficient and scalable modeling solution for structured query risk analysis. It offers practical value for intelligent optimization and performance assurance in database systems.