Memory & RAG
~8 min readUpdated: November 2026

OpenTableRAG: Enterprise Open-Domain QA Over 254M-Row SQL Databases

OpenTableRAG Enterprise Database Table QA Architecture in Smoke Monkey

OpenTableRAG (arXiv:2611.36856) scales open-domain table question answering (OTQA) to enterprise databases where tables reach 254.38M rows and 645 columns, full-table exports are prohibited, and SQL execution is resource-constrained. Using metadata-only table indexing, query-expanded schema and frequent-cell retrieval, and LLM-based Answer Selection (LAS), OpenTableRAG lifts accuracy by +46.58 percentage points (78.29% vs 31.71% Top-1 on GPT-6.1 Terra) and +41.85pp on Qwen3.8-27B.

Technical Review: Smoke Monkey Core Architecture Team
Tested on Node.js 18+ & BunTypeScript 5.x
Quick Answer & Executive Definition

OpenTableRAG: Enterprise Open-Domain QA Over 254M-Row SQL Databases: OpenTableRAG (arXiv:2611.36856) scales open-domain table question answering (OTQA) to enterprise databases where tables reach 254.38M rows and 645 columns, full-table exports are prohibited, and SQL execution is resource-constrained. Using metadata-only table indexing, query-expanded schema and frequent-cell retrieval, and LLM-based Answer Selection (LAS), OpenTableRAG lifts accuracy by +46.58 percentage points (78.29% vs 31.71% Top-1 on GPT-6.1 Terra) and +41.85pp on Qwen3.8-27B. Designed as a zero-dependency, open-source TypeScript architecture under the MIT License with native Model Context Protocol (MCP) support and deterministic phase state machines.

Key Architectural Takeaways
Quick Implementation Exampleopentablerag-sql-agent.ts
opentablerag-sql-agent.tstypescript
import { createAgent } from '@smoke-monkey/harness';
const enterpriseTableAgent = createAgent({
agentId: 'opentablerag-financial-analyst',
provider: 'ollama',
model: 'qwen3.8:27b',
workspacePath: process.cwd(),
permissions: {
read_file: 'allow',
write_file: 'ask',
run_command: 'deny',
},
mcpServers: {
tableRag: {
command: 'python3',
args: ['-m', 'opentablerag_mcp', '--top-k', '10', '--aggregation', 'las'],
},
},
});
async function answerFinancialQuery(question: string) {
const result = await enterpriseTableAgent.run(
`Retrieve top-k candidate tables via metadata index, run parallel schema and frequent-cell expansion, execute bounded SQL per table, and aggregate via LAS for: ${question}`
);
console.log('OpenTableRAG Answer:', result.summary);
}
answerFinancialQuery('Compare Q3 institutional holding deltas for semiconductor tickers').catch(console.error);
Video Guides

Watch: Related Video Guides

How to build advanced RAG systems with AI-generated SQL

Embeddings, Vector database Agent,, RAG & MCP: How Modern AI Systems Actually Work

What Is OpenTableRAG? Bridging Web Tables and 254M-Row Warehouses

Academic benchmarks such as Natural Questions (NQ) and Open-WikiTable (OWT) feature tiny static tables with a median of 6 to 11 rows and 3 to 6 columns. Production financial data platforms operate at an entirely different scale: across 578 enterprise tables, the median table holds 150,994 rows, the largest spans 254,383,645 rows and 645 columns, 47.8% update within 1 day (76.2% within 7 days), and full-table exports are prohibited.

OpenTableRAG adapts TableRAG to open-domain enterprise workloads through five stages: dense metadata table retrieval, parallel 5x query-expanded schema retrieval, top-b frequent categorical cell retrieval, resource-bounded per-table SQL reasoning, and LLM-based Answer Selection (LAS).

Enterprise Scale Comparison & OpenTableRAG Accuracy Gains

Dense retrieval over table and column metadata achieves 80.00% Hit@15 on the test split (vs 61.43% for sparse BM25), and pairing multi-table retrieval with LAS delivers over 40 percentage points of end-to-end accuracy gain.

Dataset / Evaluation SettingScale / MethodMetric / GPT-6.1 TerraMetric / Qwen3.8-27B
NQ / OWT (Academic Baselines)Median 6–11 rows, max 2,185 rowsStatic snapshotsStatic snapshots
Enterprise Financial Corpus (578 Tables)Median 150,994 rows, max 254.38M rows47.8% updated dailyZero full-table export
Open-Domain Top-1 BaselineSingle retrieved table31.71% (±0.39)29.29% (±1.52)
OpenTableRAG + SSRSemantic similarity rerank36.00% (±3.37)39.86% (±3.89)
OpenTableRAG + LASLLM-based Answer Selection78.29% (±0.39)71.14% (±1.20)
Closed-Domain Upper BoundOracle table supplied96.86% (±0.64)90.57% (±1.55)

Why LAS Crushes Similarity Reranking (SSR)

SSR only scores 36.00%–39.86% because surface embedding similarity misses whether a table actually contains executable evidence. Running reasoning across top-k tables and aggregating answers with LAS jumps to 78.29%.

Building a Zero-Export Metadata & Frequent-Cell Index

Instead of dumping gigabytes of warehouse rows into a vector database, extract INFORMATION_SCHEMA column definitions plus bounded GROUP BY frequency sketches on categorical columns.

sql
-- 1. Extract metadata-only table & column catalog for dense indexing
SELECT table_schema, table_name, column_name, data_type
FROM information_schema.columns
WHERE table_schema = 'analytics_prod'
ORDER BY table_name, ordinal_position;

-- 2. Sample top-b frequent categorical values without exporting full tables
SELECT sector_code, COUNT(*) AS freq
FROM analytics_prod.institutional_holdings
GROUP BY sector_code
ORDER BY freq DESC
LIMIT 50;
python
# Expand query into 5 schema/cell variants before dense lookup
EXPAND_PROMPT = (
    "Generate up to 5 concise SQL column or categorical value search queries "
    "for the user question without assuming exact table names: {question}"
)

Deploying Governed Table-Reasoning Agents in Smoke Monkey

Pairing OpenTableRAG's zero-export metadata index with Smoke Monkey Harness and read-only SQL execution permissions gives engineering and analytics teams accurate multi-table QA over hundreds of live tables—while keeping raw rows inside the warehouse perimeter and bounding SQL execution latency.

Google Search Questions & Answers

Frequently Asked Questions

Q:How does OpenTableRAG work if full-table exports are forbidden?

OpenTableRAG indexes only table names, column metadata, and up to `b` most-frequent categorical cell values. Actual row data stays inside the SQL database and is queried via resource-bounded SQL during table reasoning.

Q:Why does OpenTableRAG outperform Top-1 table retrieval by over 40 points?

Top-1 retrieval achieves only ~33.6% H@1 on dense enterprise metadata, capping accuracy at 31.71%. By retrieving top-k candidate tables (80% H@15), reasoning per table, and aggregating via LLM-based Answer Selection (LAS), accuracy climbs to 78.29%.

Q:Can OpenTableRAG run on open-weights models like Qwen3.8-27B?

Yes. With Qwen3.8-27B, OpenTableRAG + LAS improves open-domain accuracy from 29.29% (Top-1) to 71.14%—a +41.85 percentage point gain.

Q:How does OpenTableRAG handle tables that change every day?

Because the index stores only lightweight schema metadata and top frequent categorical values (rather than row embeddings), incremental daily refreshes across 578+ tables remain fast and inexpensive.

Related Alternatives & Comparisons

Related Architecture Guides

View all guides

Build with Smoke Monkey Harness

Zero dependencies. 24 built-in tools. Human-in-the-loop safety. 100% open source under the MIT License.

npm install smoke-monkey-harness