CSR-RAG: An Efficient Retrieval System for Text-to-SQL on the Enterprise Scale
Rajpreet Singh, Novak Boškov, Lawrence Drabeck, Aditya Gudal, Manzoor A. Khan
TL;DR
CSR-RAG addresses the enterprise Text-to-SQL retrieval bottleneck by decomposing table retrieval into semantic context, schema structure, and relational joins. It combines Contextual RAG, Structural RAG, and Relational RAG in a parallel pipeline, fused via hypergraph ranking to produce a compact set of relevant columns for SQL generation. On anonymized enterprise data, it achieves precision over 40% and recall over 80% with about 30 ms latency on commodity hardware, enabling real-time SQL generation with LLMs. The approach mitigates benchmark-realism gaps in enterprise schemas and offers a scalable, deterministic retrieval solution for large-scale databases.
Abstract
Natural language to SQL translation (Text-to-SQL) is one of the long-standing problems that has recently benefited from advances in Large Language Models (LLMs). While most academic Text-to-SQL benchmarks request schema description as a part of natural language input, enterprise-scale applications often require table retrieval before SQL query generation. To address this need, we propose a novel hybrid Retrieval Augmented Generation (RAG) system consisting of contextual, structural, and relational retrieval (CSR-RAG) to achieve computationally efficient yet sufficiently accurate retrieval for enterprise-scale databases. Through extensive enterprise benchmarks, we demonstrate that CSR-RAG achieves up to 40% precision and over 80% recall while incurring a negligible average query generation latency of only 30ms on commodity data center hardware, which makes it appropriate for modern LLM-based enterprise-scale systems.
