LLMs as Cardinality Estimators: Accurate, But Only If You Don't Call Them Every Time

Cardinality estimation is the heart of the optimizer. A team from Peking University and ByteDance fine-tunes Llama-3 8B to do CardEst, and on workloads like IMDB and STATS the 99th-percentile Q-error drops by up to 74.1% versus the strongest baseline (PRICE) — the accuracy win is real. But end-to-end, it backfires: on JOB-light and ErgastF1 the LLM’s more accurate plans are dragged down by its own inference latency, with total time exceeding even the strongest baseline PRICE. The real engineering contribution isn’t the model — it’s the gate that uses the optimizer’s own cost model as a bouncer: call the LLM only for high-cost sub-queries, leave the rest to the old methods.

May 31, 2026 · 7 min · Kent Yao