cd /news/large-language-models/how-uber-scaled-text-to-sql-to-1-2m-… · home › topics › large-language-models › article
[ARTICLE · art-176240] src=dev.to ↗ pub= topic=large-language-models verified=true sentiment=↑ positive

How Uber Scaled Text-to-SQL to 1.2M Monthly Queries: Inside QueryGPT's Multi-Agent Architecture

Uber detailed how it evolved QueryGPT, a 2023 hackathon prototype, through 20+ iterations into a multi-agent text-to-SQL pipeline serving roughly 1.2 million interactive queries per month and cutting average query authoring time from about 10 minutes to about 3. The system replaces single-pass RAG with a progressive filtering funnel—an Intent Agent routing prompts across 12 curated System Workspaces, a Table Agent with a human-in-the-loop checkpoint, a Column Prune Agent, and a final SQL generation step—after naive retrieval broke down on wide tables exceeding 200 columns and 40K–60K tokens each.

recommendation

Scope retrieval to curated domain workspaces and prune columns before generating SQL; Uber found naive top-3 table RAG overflowed 128K tokens and returned zero-row queries from wrong enum guesses.

more in playbook: Designing agent systems
by read6 min views2 publishedNov 25, 2026

Most Text-to-SQL demos look impressive on a 5-table toy database and fall apart the moment they meet an enterprise data warehouse. The bottleneck isn't SQL syntax—it's context bloat, ambiguous domain boundaries, and tribal schema knowledge.

In their engineering deep dive, QueryGPT – Natural Language to SQL Using Generative AI, Uber shared how they evolved a 2023 hackathon prototype through 20+ iterations into a production system serving ~1.2 million interactive queries per month (with Operations alone driving ~36% of volume), cutting average query authoring time from ~10 minutes down to ~3 minutes.

Here is an architectural breakdown of why naive RAG failed at Uber's scale—and the multi-agent pipeline they built to fix it.

#

  1. Why V1 Naive RAG Collapsed at Scale

Uber's initial May 2023 prototype (Hackdayz V1) followed a classic single-pass RAG pattern:

  1. Embed the user's natural language prompt.
  2. Run k-nearest neighbor (k-NN) similarity search across a small pool of 7 Tier-1 tables and20 sample SQL queries .
  3. Retrieve the top 3 tables andtop 7 SQL samples , combine them with custom Uber business instructions (such as date formatting rules), and generate SQL in one LLM call.
flowchart LR
    P["User Natural Language Prompt"] --> E["Vector Embedding + k-NN Search"]
    E --> R1["Top 3 Table DDLs"]
    E --> R2["Top 7 SQL Samples"]
    C["Custom Uber Date & Business Rules"] --> LLM["Single LLM Call"]
    R1 --> LLM
    R2 --> LLM
    LLM --> OUT["SQL Query + Explanation"]

As Uber onboarded more datasets into production, three systemic bottlenecks broke this architecture:

DDL Embedding Mismatch: Vector similarity between a plain-English business question ("trips completed yesterday in Seattle" ) and rawCREATE TABLE DDL statements degraded rapidly as hundreds of tables were added. #

Context Window Exhaustion: Wide Tier-1 tables at Uber often exceed200+ columns , consuming40K–60K tokens per table . Retrieving just three tables blew past early 32K token limits—and continued causing intermittent overflows even after upgrading toGPT-4 Turbo (1106) with a 128K token window . #

Silent Semantic Hallucinations: Queries frequently compiled and executed without syntax errors while returning zero rows because the LLM guessed wrong enum values (e.g., filteringstatus = 'Finished' when the table stores'Completed' ).

#

  1. Production Architecture: A Progressive Filtering Funnel

Instead of dumping raw schemas into a single prompt, Uber redesigned QueryGPT as a multi-stage agentic pipeline that progressively narrows the search radius before generating SQL.

flowchart TD
    U["User Prompt: Tesla trips completed in Seattle yesterday"] --> IA["1. Intent Agent"]
    IA --> WS["Domain Workspace Routing: Mobility selected out of 12 System Workspaces"]
    WS --> RAG["Scoped Vector Search: Mobility Tables & SQL Samples"]
    RAG --> TA["2. Table Agent"]
    TA --> HITL{"Human-in-the-Loop Checkpoint"}
    HITL -- "User edits table list" --> TA
    HITL -- "User clicks Looks Good" --> CPA["3. Column Prune Agent"]
    CPA --> SLIM["Pruned Schemas: Irrelevant Columns Stripped"]
    SLIM --> GEN["4. SQL Generation LLM + Custom Date Rules"]
    GEN --> FINAL["Verified SQL Query + Plain-English Explanation"]

Stage 1: Domain Workspaces + Intent Agent

Uber partitioned its data catalog into 12 curated System Workspaces—** Mobility** plus 11 other core domains including Ads (Uber Advertising), Core Services, Platform Engineering, and IT (Information Technology)—alongside user-defined Custom Workspaces for specialized teams.

Every request first hits an Intent Agent (an LLM classifier) that maps the prompt to one or more workspaces. By locking onto the Mobility workspace first, QueryGPT avoids searching unrelated Ads or IT schemas altogether.

Stage 2: Table Agent with Human-in-the-Loop (HITL)

Early user feedback revealed that when upstream table retrieval missed the mark, the final SQL was guaranteed to fail. Uber introduced a Table Agent paired with an explicit UI checkpoint:

  • The agent proposes candidate tables (e.g., uber.trips_data anduber.dim_city ).
  • The user can either click "Looks Good" to proceed or manually add/remove tables before SQL synthesis begins.

Stage 3: Column Prune Agent

To eliminate 128K token overflows and reduce inference latency, Uber added a Column Prune Agent. Before generating SQL, an intermediate LLM call inspects the user's question and strips out irrelevant columns from each selected table's DDL—shrinking a 200-column schema down to only the handful of fields needed for joins, filters, and projections.

#

  1. Complete End-to-End Walkthrough

Here is how a real request flows through every stage of the pipeline (note: uber.trips_data is an illustrative table name used in Uber's blog):

User Prompt: >"Write a query to find the number of trips that were completed by Teslas in Seattle yesterday" 2. Intent Agent Output: Maps prompt to the**Mobility** system workspace. 3. Table Agent + User Confirmation: Suggestsuber.trips_data anduber.dim_city → User clicks**"Looks Good"** . 4. Column Prune Agent Output: Reducesuber.trips_data from 200+ columns down totrip_id ,city_id ,vehicle_make ,trip_status , anddatestr (partition key). 5. Final Generated SQL (incorporating Uber's custom date instructions):

(Accompanied by a plain-English explanation of the join, filter conditions, and date partition logic.)

#

  1. How Uber Evaluates QueryGPT (Vanilla vs. Decoupled)

Because LLM outputs are non-deterministic (~5% run-to-run variance), Uber built a golden question-to-SQL benchmark and tracks regressions across two test modes:

Vanilla Flow: End-to-end execution where QueryGPT infers intent, tables, and SQL autonomously. #

Decoupled Flow: Injects ground-truth intent and tables directly into the generator so engineers can isolate SQL synthesis quality from upstream retrieval errors.

flowchart LR
    G["Golden Benchmark Question"] --> M1["1. Intent Accuracy"]
    G --> M2["2. Table Overlap Score: 0.0 to 1.0"]
    G --> M3["3. Successful Run: Compiles & Executes"]
    G --> M4["4. Run Has Output: Rows Greater Than 0"]
    G --> M5["5. Qualitative Query Similarity: LLM Judge 0.0 to 1.0"]

Each benchmark run captures 5 distinct signals:

Intent Accuracy: Did the Intent Agent select the right workspace? 2. Table Overlap (0 to 1): Measures retrieval precision. For example, if*"How many trips were canceled by drivers last week in Los Angeles?"* requires[fact_trip_state, dim_city] and QueryGPT selects[dim_city, fact_eats_trip] , the overlap score is0.5 (1 of 2 required tables matched). 3. Successful Run: Does the SQL execute on the engine without syntax or missing-partition errors? 4. Run Has Output (rows > 0): Catches silent semantic bugs—such as WHERE status = 'Finished' instead of'Completed' —where a query runs cleanly but returns zero records. 5. Qualitative Query Similarity (0 to 1): An LLM judge compares the generated SQL against the golden SQL to verify whether joins, columns, and aggregations are structurally sound even when a minor rule (like a missing partition filter) causes execution to fail.

#

Key Architectural Takeaways

Bound your retrieval space first: Domain workspaces + an Intent Agent outperform flat vector search across monolithic enterprise catalogs. 2. Put humans at high-leverage checkpoints: Confirming 2–3 table names takes a user two seconds and prevents cascading hallucination in the final SQL. 3. Prune schemas aggressively: Treating DDL pruning as its own lightweight agentic step cuts token cost, prevents context overflows, and improves SQL attention accuracy. 4. Measure silent failures, not just syntax: A Text-to-SQL query that compiles with zero rows returned is a failure—track non-empty execution alongside structural similarity.

── more in #large-language-models 4 stories · sorted by recency
── more on @uber 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/how-uber-scaled-text…] indexed:0 read:6min 2026-11-25 · —