← Key papers

Paper review · November 17, 2026

MEM-SQL: Memory-Based Text-to-SQL

MEM-SQL: Memory-Empowered Text-to-SQL

Language modelsData engineeringData & evaluation Intermediate Upvotes 17 cs.DB The University of Hong Kong

The system stores verified past SQL in a three-layer memory of templates, query blocks and schema concepts, and looks up the schema only when needed, improving accuracy while sharply cutting input tokens and latency.

Problem

Benchmarks such as Spider and BIRD evaluate each question independently. In practice, however, the same DB is queried repeatedly, so previously verified queries can supply join or calculation logic. There was no standard for measuring the accuracy and cost of reusing past queries. It was also unclear what to remember and when to judge that retrieval results are sufficient.

Method

First, the authors built the HARE benchmark. Starting from 823 verified queries selected from Spider, BIRD, Spider 2.0 and BEAVER, they created 1,600 requests and annotated their reuse types across 6 basic and 6 composite categories. The requests were generated with GLM5.3-Flash and reviewed with Claude Opus 5.5. MEM-SQL stores past queries in three layers: slotted full-query templates, reusable SELECT blocks (components), and schema concepts that link domain terms to columns and joins. Each question is broken down into per-layer requirement units (atoms). A layer is used only when every atom finds a match above a threshold (Coverage Gate). OSL (On-demand Schema Linking) looks up the schema only when no layer is used or when the generator judges that the evidence is insufficient.

Results

Limitations

HARE requests were generated and checked by LLMs, so they may differ from the distribution of real user queries. The memory is built only from a verified history that stays fixed during evaluation; cases where the history keeps growing or contains incorrect queries are not covered. Combining multiple queries remains a bottleneck for all methods.

Why it matters

In enterprise data analysis, similar queries are run repeatedly against the same database. The work shows that breaking verified SQL history into small pieces and reusing them can improve accuracy and cost at the same time. It is a practical alternative to feeding the entire schema in every time.

Key terms

Text-to-SQL
The task of turning a natural-language question into an SQL query that can be run on a database.
Schema Linking
The step of finding the tables and columns a question needs in the database schema and linking them to the question. It is costly for large databases.
Coverage Gate
A rule that uses a memory layer only when every requirement in that layer is matched above a threshold. It prevents one strong match from hiding other gaps.
Execution accuracy (EX)
The share of generated SQL queries whose execution results match those of the reference query.

Original

Authors: Xiaoqi Wang, Wenqi Pei, Shizheng Hou, Yilai Liu, Han Chen, Boyan Li, Yuyu Luo, Hongyang Du · Posted 2026-11-13 · License CC BY 4.0 · Based on the full text

This review is an AI-written summary of the paper. Please treat the original paper as the reference.