Cost-Aware Text-to-SQL: An Empirical Study of Cloud Compute Costs for LLM-Generated Queries
Saurabh Deochake, Debajyoti Mukhopadhyay
TL;DR
This study introduces a cloud-native, cost-focused evaluation of LLM-generated Text-to-SQL on Google BigQuery using the StackOverflow dataset, revealing that reasoning-models reduce cloud compute costs by about $44.5\%$ compared with standard models while maintaining near-perfect correctness. It demonstrates a weak link between execution time and cost, showing that faster queries do not imply cheaper ones, and highlights substantial cost variance across models driven by inefficiency patterns such as missing partition filters and unnecessary full-table scans. The authors provide practical deployment guidelines and a framework for cost-aware benchmarking, emphasizing the need for explicit cloud-cost metrics in production. The work lays groundwork for cost-aware prompt design, model selection, and operational policies in enterprise settings for Text-to-SQL systems.
Abstract
Text-to-SQL systems powered by Large Language Models (LLMs) achieve high accuracy on standard benchmarks, yet existing efficiency metrics such as the Valid Efficiency Score (VES) measure execution time rather than the consumption-based costs of cloud data warehouses. This paper presents the first systematic evaluation of cloud compute costs for LLM-generated SQL queries. We evaluate six state-of-the-art LLMs across 180 query executions on Google BigQuery using the StackOverflow dataset (230GB), measuring bytes processed, slot utilization, and estimated cost. Our analysis yields three key findings: (1) reasoning models process 44.5% fewer bytes than standard models while maintaining equivalent correctness (96.7%-100%); (2) execution time correlates weakly with query cost (r=0.16), indicating that speed optimization does not imply cost optimization; and (3) models exhibit up to 3.4x cost variance, with standard models producing outliers exceeding 36GB per query. We identify prevalent inefficiency patterns including missing partition filters and unnecessary full-table scans, and provide deployment guidelines for cost-sensitive enterprise environments.
