解决企业级NL2SQL在复杂数据库中因上下文过载导致失效的问题。
DRL: A Deterministic Relational Middleware Layer for Transaction-Safe Enterprise NL2SQL Under Schema-Graph Scaling

- 构建确定性中间层,通过动态剪枝和事务验证控制上下文规模。
- 上下文减少92%,关键查询执行匹配率达52.9%以上。
- 适合关注企业级数据库安全与稳定性的系统设计者。
在企业OLTP目录上部署自然语言接口在规模扩大时会因语义解析器在模式图扩展下失效而失败,导致上下文超出大模型注意力预算。本文提出DRL(确定性关系中间层),作为前端与后端之间的安全管道。DRL包含动态上下文剪枝、关系抽象语法树类型化及事务保障验证(EXPLAIN门控与空值防护),以限制上下文并标记操作性隐性偏差(SDop)。我们在PostgreSQL和MySQL上评估DRL,贡献了:(i) 一个OLTP模式图扩展模型,(ii) 1,000对工作负载验证套件,(iii) 基线B0-B3,以及 (iv) 企业NL2SQL失败分类法。在PostgreSQL上,基于模式链接提示(B1)相比原始全模式提示(B0)实现76%上下文减少;DRL动态路由(B2)达到92%减少,剪枝p95为0.58毫秒,中间件p95为4.6毫秒。GPT-4o、Claude Sonnet 4.5和Gemini 2.5 Flash在修正评估框架下分别获得52.9%、52.8%、52.1%的执行匹配率;SDop可标记89%-100%的虚假通过查询。GPT-4o错误主要源于语义/过滤错误(254/471),列幻觉影响较小(47/471)。值得注意的是,评估后处理中的单个正则缺陷曾无声掩盖准确率并制造出4%-10%跨厂商差距,修正后该差距消失,表明基准代码需与模型同等严谨对待。DRL将企业级NL2SQL重定义为系统工程——上下文约束、验证与计划感知准入,而非排行榜竞赛。
原文摘要 · Abstract (English)
Deploying natural-language interfaces over enterprise OLTP catalogs fails at scale because semantic parsers collapse under schema-graph scaling, inflating context beyond stable LLM attention budgets. We present DRL (Deterministic Relational Middleware Layer), a safe pipeline interposing between front-ends and SQL backends. DRL comprises dynamic context pruning, relational AST typing, and transactional safeguard verification (EXPLAIN gating and NULL guards) to bound context and flag operational silent divergence (SDop). We evaluate DRL on PostgreSQL and MySQL, contributing (i) an OLTP schema-graph scaling model, (ii) a 1,000-pair Workload Verification Suite, (iii) baselines B0-B3, and (iv) an enterprise NL2SQL failure taxonomy. On PostgreSQL, schema-linked hints (B1) yield a 76% context reduction over naive full-catalog prompting (B0); DRL's dynamic router (B2) reaches a 92% reduction at pruning p95 = 0.58 ms and middleware p95 = 4.6 ms. GPT-4o, Claude Sonnet 4.5, and Gemini 2.5 Flash achieve 52.9%, 52.8%, and 52.1% execution match under a corrected evaluation harness; SDop flags 89-100% of false-positive EX-passing queries. GPT-4o failures are dominated by semantic/filter errors (254/471), while column hallucination is a minor factor (47/471). Crucially, a single regex defect in our evaluation post-processor silently suppressed accuracy and manufactured a false 4-10% cross-vendor gap that vanished when corrected, showing that benchmark code deserves the same scrutiny as the models it scores. DRL reframes enterprise NL2SQL as systems engineering - context bounding, verification, and plan-aware admission - not a leaderboard exercise.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。