行业动态
techxplore.com ·
'安全查询空间'让AI修复SQL错误而无需重来
研究人员提出'安全查询空间'方法,使AI系统在查询数据库出错时能局部修复,而无需重新生成整个SQL查询。该方法有望提高AI数据库交互的效率和准确性。
AI推荐理由 介绍了一种'安全查询空间'方法,让AI修复SQL错误而无需从头开始,对数据库查询优化有实际价值,技术细节具体。
75
正文
September 4, 2026
'Safe query space' lets AI fix SQL errors without starting over
by The Korea Advanced Institute of Science and Technology (KAIST)
edited by
Sadie Harley, reviewed by Robert Egan
Sadie Harley
Scientific Editor
Meet our editorial team
Behind our editorial process
Robert Egan
Senior Editor
Meet our editorial team
Behind our editorial process
Editors' notes
This article has been reviewed according to Science X's
editorial process
and policies.
Editors have highlighted
the following attributes while ensuring the content's credibility:
fact-checked
trusted source
proofread
The GIST
Add as preferred source
Comparison of the SQL error correction processes used by conventional methods and SafeQL. Credit: KAIST
"Find the best-selling product from last year." When an AI system attempts to answer a question like this by querying a company database, even a single reference to a nonexistent item can cause the query to fail. Until now, correcting such an error often required regenerating the entire SQL query from scratch.
A research team led by Professor Min-Soo Kim from the School of Computing has developed SafeQL, a technology that instead identifies and fixes only the erroneous part. The technology is expected to make AI-powered data retrieval faster and more accurate, accelerating the adoption of AI work assistants in enterprise environments.
The findings were presented at the International Conference on Very Large Data Bases (VLDB), held in Boston, U.S., from Sept. 1–5.
Text-to-SQL technology enables AI systems to convert everyday questions, such as "Which product saw the largest increase in sales last year?" or "Which items are running low in stock?" into SQL queries. This allows users to retrieve sales, customer and inventory data using natural language without having to understand complex database commands.
However, AI systems can make mistakes when generating SQL. For example, they may refer to a table or column that does not exist or join tables incorrectly. These errors can prevent the query from running and leave the AI unable to retrieve the requested data.
SafeQL's efficient SQL search process using pruning. Credit: KAIST
Rewriting one word at a time
Conventional correction methods send the database error back to a large language model (LLM) and ask it to regenerate the entire query. This is similar to rewriting an entire report to correct a single word. In the process, parts that were already correct may be altered, new errors may be introduced, and repeated calls to the LLM increase both cost and processing time.
SafeQL takes a different approach. Instead of discarding and regenerating the entire query after an execution failure, it interprets feedback from the database management system to precisely locate the faulty component, such as a relation, attribute, function or value. It then incrementally repairs that component while preserving the valid structure and logic of the original query.
To achieve this, the research team developed a "safe query space" approach. Among the candidate corrections that can be executed on the database, SafeQL searches for the one closest to the query originally generated by the AI. The system prioritizes the most promising candidates and filters out unsuitable ones in advance, reducing the time required for correction.
The team implemented SafeQL as a PostgreSQL extension and integrated it with the database system's parser, binder and type analyzer. This enables SafeQL to precisely locate errors even in complex SQL queries. The system calls the LLM again when search-based refinement cannot resolve the error within a predefined threshold, thereby reducing unnecessary AI use.
Benchmark gains and enterprise use
The research team evaluated SafeQL using BIRD and Spider, two widely used benchmarks for assessing the database querying capabilities of AI systems.
On the BIRD benchmark, SafeQL resolved execution errors in up to 87.4% of initially erroneous SQL queries and improved execution accuracy by up to 5.8 percentage points over the unrefined baseline. Compared with regenerating the entire query, SafeQL reduced token use by a factor of up to 15.1 and refinement latency by a factor of up to 29.6.
SafeQL is expected to be particularly useful for enterprises that handle large volumes of data requests. If an error occurs while an AI system is searching internal sales, customer or inventory data, SafeQL can repair only the affected part instead of regenerating the entire query. This can reduce the cost and time required to operate enterprise AI systems and support reliable work automation powered by AI agents and corporate data.
Professor Kim said, "For AI to perform real-world tasks in enterprise environments, it must be able to accurately retrieve the data it needs."
He added, "When AI makes an error during a database search, SafeQL fixes only the affected part instead of starting over from scratch. By reducing errors, costs and processing time, we expect the technology to accelerate reliable AI-powered work automation."
Geonho Lee, a Ph.D. student in the KAIST School of Computing, participated in the study as first author, with Professor Kim serving as corresponding author.
More information
Geonho Lee et al, SafeQL: Search-based Refinement for Safe and Efficient LLM-based Text-to-SQL, Proceedings of the VLDB Endowment (2026). DOI: 10.14778/3819518.3819545
SafeQL: safeql.dev/
Provided by
The Korea Advanced Institute of Science and Technology (KAIST)
Who's behind this story?
Sadie Harley
BSc Life Sciences & Ecology. Microbiology lab background with pharmaceutical news experience in oil, gas, and renewable industries.
Full profile →
Robert Egan
Bachelor's in mathematical biology, Master's in creative writing. Well-traveled with unique perspectives on science and language.
Full profile →
Citation:
'Safe query space' lets AI fix SQL errors without starting over (2026, September 4)
retrieved 8 September 2026
from https://techxplore.com/news/2026-09-safe-query-space-ai-sql.html
This document is subject to copyright. Apart from any fair dealing for the purpose of private study or research, no
part may be reproduced without the written permission. The content is provided for information purposes only.
Next-generation database reduces AI hallucinations and improves accuracy by 78%
Jun 19, 2026
AI fixes 'temporal errors,' enhancing reliability in medical and legal fields
Apr 14, 2026
Researchers introduce generative AI to analyze complex tabular data
Jul 8, 2024
Researchers develop a next-generation graph-relational database system
Sep 8, 2025
New system efficiently explains AI judgments in real-time
Dec 12, 2025
New AI model can help prevent damaging and costly data breaches
Nov 8, 2022
Memristor chip breaks the capacity limit of brain-inspired associative memory
5 hours ago
Invention may bring smart bionic eye into sight
4 hours ago
Whole-body expansion and contraction make a robot seem more alive
6 hours ago
A tiny crystal tilt may bring greener magnetic memory closer to everyday devices
6 hours ago
Tracking energy flow reveals voltage pattern that slashes waste heat by over 60%
8 hours ago
Editorial proposes limits on generative AI's role in scientific research
12 hours ago