EllieSQL: Cost-Efficient Text-to-SQL with Complexity-Aware Routing

Yizhang Zhu, Runzhi Jiang, Boyan Li, Nan Tang, Yuyu Luo

TL;DR

This paper introduces EllieSQL, a novel framework that tackles the "elephant in the room" of Text-to-SQL: prohibitively high computational costs. By intelligently routing queries to different SQL generation pipelines based on their estimated complexity, EllieSQL significantly reduces token usage (over 40% reduction) without sacrificing performance. They also introduce a new metric, Token Elasticity of Performance (TEP), to better quantify cost-efficiency.

What Problem Does This Paper Address?

Large Language Models (LLMs) have revolutionized Text-to-SQL, enabling non-technical users to query databases. However, the most advanced LLM-based approaches often employ computationally intensive methods for all queries, regardless of their complexity. This leads to massive token consumption, making these systems economically unsustainable for real-world deployment. The paper argues that this "unsustainable computational cost" is a critical, yet often overlooked, limitation hindering widespread adoption.

Methods

EllieSQL proposes a three-phase framework:

  1. Schema Linking: Identifies relevant tables and columns for a given query, reducing input complexity.
  2. Complexity-Aware Routing: This is the core innovation. A router estimates the complexity of a query (based on the natural language query and the filtered schema) and directs it to one of three tiered SQL generation pipelines:
  3. Basic (GB): Lightweight, low-cost for simple queries.
  4. Intermediate (GM): Uses a "Divide-and-Conquer" Chain-of-Thought strategy for moderately complex queries.
  5. Advanced (GA): Employs online synthesis for the most complex queries, offering the highest performance but at the greatest cost.
  6. Tiered SQL Generation Pipelines: The actual generation of SQL queries, tailored to the complexity level assigned by the router.

A key contribution is the Token Elasticity of Performance (TEP) metric, inspired by economics. TEP quantifies how much performance improves relative to the increase in token investment, providing a standardized way to measure cost-efficiency.

Datasets

  • Bird: Used for training and development. Notably, the training and development sets are from entirely separate databases, challenging the routers to generalize.
  • Spider-dev, Spider-Realistic-dev, Spider-test: Used for out-of-distribution (OOD) evaluation to assess generalizability.

Key Insights and Ideas

  • Complexity is Key: Not all Text-to-SQL queries are created equal. Applying the most sophisticated method to every query is wasteful.
  • Cost-Efficiency Matters: Performance alone isn't enough for real-world adoption. Computational cost is a major bottleneck.
  • TEP as a Better Metric: Traditional metrics like Execution Accuracy (EX) don't capture the cost-performance trade-off. TEP offers a more holistic view.
  • Routing is More Than Just Model Selection: While LLM routing is an active area, EllieSQL focuses on routing to different generation pipelines, which is crucial for Text-to-SQL.
  • Generalization is Achievable: EllieSQL's routers demonstrate strong performance even on unseen databases, highlighting the framework's robustness.

Key Results

  • Significant Cost Reduction: EllieSQL, particularly with the Qwen2.5-0.5B-DPO router, reduced token usage by over 40% compared to always using the most advanced pipeline (GA) on the Bird development set, without sacrificing performance.
  • Improved TEP: Achieved more than a 2x boost in TEP compared to non-routing approaches.
  • Competitive Performance: Routing approaches like Qwen DPO and RoBERTa SFT achieved performance comparable to, or even slightly exceeding, the standalone advanced pipeline (GA).
  • OOD Generalizability: EllieSQL maintained high performance and reduced token costs on Spider datasets, demonstrating its ability to generalize to unseen databases.
  • Efficiency Gains: Reduced total processing time by over 40% on the Bird dev set.

Limitations and Future Work

  • Labeled Training Data: Router training requires labeled data, which incurs an upfront cost.
  • Limited Routers/Pipelines: The study explored three base methods and router categories; future work could explore more advanced pipelines (e.g., MCTS) and router types.
  • Dependency on Schema Linking: Errors in the schema linking phase can propagate to subsequent routing and generation.
  • Retraining Routers: Introducing new SQL generation pipelines requires retraining routers, adding incremental costs.

Future work could focus on:

  • Data-efficient router training (even training-free routing).
  • Developing more scalable and generalizable routers.
  • Improving the robustness of schema linking.

Summary updated

BibTeX
@inproceedings{zhu2025elliesql,
  author = {Yizhang Zhu and Runzhi JIANG and Boyan Li and Nan Tang and Yuyu Luo},
  title = {{EllieSQL: Cost-Efficient Text-to-SQL with Complexity-Aware Routing}},
  booktitle = {COLM},
  year = {2025},
  url = {https://openreview.net/forum?id=8OqGNXKwo8},
}
Figure