Query Performance Explanation through Large Language Model for HTAP Systems

Haibo Xiu,Li Zhang,Tieying Zhang,Jun Yang,Jianjun Chen
2024-12-03
Abstract:In hybrid transactional and analytical processing (HTAP) systems, users often struggle to understand why query plans from one engine (OLAP or OLTP) perform significantly slower than those from another. Although optimizers provide plan details via the EXPLAIN function, these explanations are frequently too technical for non-experts and offer limited insights into performance differences across engines. To address this, we propose a novel framework that leverages large language models (LLMs) to explain query performance in HTAP systems. Built on Retrieval-Augmented Generation (RAG), our framework constructs a knowledge base that stores historical query executions and expert-curated explanations. To enable efficient retrieval of relevant knowledge, query plans are embedded using a lightweight tree-CNN classifier. This augmentation allows the LLM to generate clear, context-aware explanations of performance differences between engines. Our approach demonstrates the potential of LLMs in hybrid engine systems, paving the way for further advancements in database optimization and user support.
Databases,Computation and Language,Machine Learning
What problem does this paper attempt to address?
This paper attempts to solve the problem that in a hybrid transaction and analytical processing (HTAP) system, it is difficult for users to understand why the query plan from one engine (OLAP or OLTP) is much slower than that from the other engine. Although the optimizer provides detailed execution plan information through the EXPLAIN function, these explanations are too technical for non - expert users and offer limited insights into the performance differences between different engines. ### Specific Problem Description 1. **Problem Background**: - In modern database management systems (DBMS), users are often at a loss to understand why certain queries take a very long time to execute. - Although the EXPLAIN feature currently provided by the optimizer details the execution plan, it is still difficult for non - expert users to understand. - This challenge is particularly evident in HTAP systems, such as the ByteHTAP system developed by ByteDance, which has a unified interface and two underlying execution engines: OLTP (Online Transaction Processing, abbreviated as TP) and OLAP (Analytical Processing, abbreviated as AP). 2. **Specific Problems**: - Users need guidance to select the optimal engine and understand why one engine may perform better than another. - Traditionally, database experts manually analyze queries to provide customized explanations, but as the volume of queries grows, this method becomes unsustainable. ### Paper Solution To solve this problem, the authors propose a new framework that utilizes large - language models (LLMs) to explain query performance in HTAP systems. The main features of this framework include: - **Retrieval - Augmented Generation (RAG) - based Method**: A knowledge base is constructed to store historical query executions and expert - curated explanations. - **Light - weight Tree - CNN Classifier**: Used to embed query plans, enabling LLMs to generate clear, context - relevant explanations of performance differences. - **Balancing Cost and Accuracy**: Using pre - trained public models in combination with the RAG method solves the problem of general LLMs lacking specific context while maintaining efficiency. ### Goals This framework aims to meet the following three key criteria: 1. The explanations should be clear and easy to understand for non - expert users. 2. The explanations must take into account the context of the database and the engines to ensure that the output is reasonably accurate. 3. The solution must be cost - effective in terms of training and maintenance. By integrating LLMs into HTAP systems, this framework helps users understand the performance differences between different engines, demonstrates the potential of LLMs in providing intuitive and easy - to - understand explanations, and paves the way for more comprehensive research on automated database performance analysis in the future.