cs.SEMar 23, 2026

LLM-Based Test Case Generation in DBMS through Monte Carlo Tree Search

Authors: Yujia Chen, Yingli Zhou, Fangyuan Zhang, Cuiyun Gao

Organizations: Harbin Institute of Technology, Shenzhen, Shenzhen, China · The Chinese University of Hong Kong, Shenzhen, Shenzhen, China · Huawei Hong Kong Research Center, Hongkong, China

Abstract

Database Management Systems (DBMSs) are fundamental infrastructure for modern data-driven applications, where thorough testing with high-quality SQL test cases is essential for ensuring system reliability. Traditional approaches such as fuzzing can be effective for specific DBMSs, but adapting them to different proprietary dialects requires substantial manual effort. Large Language Models (LLMs) present promising opportunities for automated SQL test generation, but face critical challenges in industrial environments. First, lightweight models are widely used in organizations due to security and privacy constraints, but they struggle to generate syntactically valid queries for proprietary SQL dialects. Second, LLM-generated queries are often semantically similar and exercise only shallow execution paths, thereby quickly reaching a coverage plateau. To address these challenges, we propose MIST, an LLM-based test case generatIon framework for DBMS through Monte Carlo Tree search. MIST consists of two stages: Feature-Guided Error-Driven Test Case Synthetization, which constructs a hierarchical feature tree and uses error feedback to guide LLM generation, aiming to produce syntactically valid and semantically diverse queries for different DBMS dialects, and Monte Carlo Tree Search-Based Test Case Mutation, which jointly optimizes seed query selection and mutation rule application guided by coverage feedback, aiming at boosting code coverage by exploring deeper execution paths. Experiments on three widely-used DBMSs with four lightweight LLMs show that MIST achieves average improvements of 43.3% in line coverage, 32.3% in function coverage, and 46.4% in branch coverage compared to the baseline approach with the highest line coverage of 69.3% in the Optimizer module.

Figures & tables

Explore similar work

CardsList
  1. Are LLMs Overkill for Databases?: A Study on the Finiteness of SQL

    Mar 26, 2026Yue Li, David Mimno, Unso Eun Seo JoText-to-SQLQuery Complexity

  2. PLSQLBench: Benchmarking LLM Systems for Executable Procedural Database Programming

    Aug 16, 2026Marianne Menglin Liu, Leonid Boytsov, Daniel W. Peterson +13Code Generation BenchmarksLLM Code Generation

  3. ACTS-SQL: Agentic and Critic-Oriented Tree-Structured SQL Correctness with Large Language Models

    Aug 15, 2026Xinmei Huang, Jie Song, Peng Li +10Text-to-SQLLLM Self-Correction