Q-Doctor: Retrieval-Augmented Diagnosis and Multi-agent Correction for Query Performance Anomalies
摘要
The stability and efficiency of database systems are critical to numerous data-intensive applications. However, it remains challenging to keep stable and high query performance, particularly under complex analytical workloads where subtle performance anomalies would cause significant latency and resource inefficiencies. Existing approaches often separate diagnosis from correction—focusing either on detecting execution anomalies or on black-box tuning techniques with limited interpretability and generality. In this paper, we propose Q-Doctor, a Query-level retrieval-augmented framework for Diagnosing and correcting database performance. First, Q-Doctor jointly encodes both query semantics and execution behaviors via a hybrid representation combining graph and tree neural encoders. This representation enables efficient retrieval of similar historical cases, which then guides an informed and fine-grained diagnosis. Moreover, a multi-agent correction module is introduced to collaboratively refine SQL hints and system configurations via reinforcement-guided iterations. Extensive experiments on well-established benchmarks demonstrate that Q-Doctor could accurately identify hidden performance anomalies and significantly improve query performance.