Skip to main content
QUICK REVIEW

[Paper Review] LLM-Based Test Case Generation in DBMS through Monte Carlo Tree Search

Yujia Chen, Yingli Zhou|arXiv (Cornell University)|Mar 23, 2026
Software Testing and Debugging TechniquesComputer Science0 citations
TL;DR

MIST uses lightweight LLMs guided by a hierarchical feature tree and Monte Carlo Tree Search to generate SQL test cases for DBMSs, improving code coverage across parsing, optimization, execution, and storage.

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.

Motivation & Objective

  • Motivate robust testing of DBMSs by generating high-quality SQL test cases that capture diverse dialects and deeper execution paths.
  • Overcome DAL/semantic gaps by using a feature-guided, error-driven synthesis stage and an MCTS-based mutation stage.
  • Achieve higher code coverage across DBMS components using only locally deployed lightweight LLMs.
  • Demonstrate generalizability across DBMS architectures and varying LLM sizes with extensive experiments.

Proposed method

  • Construct a hierarchical feature tree from official DBMS documentation to guide LLM-based test case generation.
  • Use error feedback from executed tests to iteratively refine LLM prompts (feature-guided, error-driven synthesis).
  • Apply Monte Carlo Tree Search to mutate and extend test cases, guided by coverage feedback, using 135 dialect-aware mutation rules.
  • Treat test case success as an implicit oracle focusing on syntax validity and runtime stability rather than functional correctness.
  • Post-process generated SQL to ensure executability and eliminate non-SQL content before execution.
Figure 1 . An illustrative example of using Qwen2.5-7B to generate a SQL test case for DBMS.
Figure 1 . An illustrative example of using Qwen2.5-7B to generate a SQL test case for DBMS.

Experimental results

Research questions

  • RQ1RQ1: How effectively does MIST improve code coverage for DBMSs compared to a baseline?
  • RQ2RQ2: How does MIST perform across different DBMS modules (Parser, Optimizer, Executor, Storage)?
  • RQ3RQ3: What is the contribution of the two stages (synthetization and mutation) to coverage improvement?
  • RQ4RQ4: Do results generalize across different LLM sizes and DBMS architectures?

Key findings

  • MIST yields average improvements of 43.3% in line coverage, 32.3% in function coverage, and 46.4% in branch coverage versus the baseline.
  • MIST achieves the highest line coverage in the Optimizer module (69.3% for DuckDB and 63.4% for PostgreSQL).
  • Improvements are observed across DuckDB, PostgreSQL, and SQLite and across all four evaluated LLMs, including smaller models outperforming larger baselines.
  • Module-level results show substantial gains across Parser, Optimizer, Executor, and Storage for DuckDB and PostgreSQL.
Figure 3 . The overview of MIST.
Figure 3 . The overview of MIST.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.