← Latest papers
🤖 machine learning

When Does q-error Predict Plan Regret? Three Regimes of Cardinality-Estimation Error

This paper demonstrates that while q-error is a poor predictor of query-plan regret for large cardinality estimation errors typical of learned estimators, a new metric called ACS-infinity effectively identifies regret-prone queries by characterizing the geometry of the plan-cost landscape across three distinct error regimes.

Original authors: Madhulatha Mandarapu, Sandeep Kunkunuru

Published 2026-06-16
📖 5 min read🧠 Deep dive

Original authors: Madhulatha Mandarapu, Sandeep Kunkunuru

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are trying to navigate a city to get to a destination as quickly as possible. You have a map (the database query optimizer) and a GPS (the cardinality estimator) that tells you how many cars are on each road.

The problem is that your GPS is sometimes wrong. Sometimes it thinks a road is empty when it's actually jammed, or vice versa. When the GPS is wrong, you might pick a route that takes 30 minutes instead of the optimal 3 minutes. This difference is called "plan regret."

For a long time, researchers tried to measure how "bad" the GPS was using a single number called q-error. They assumed that if the q-error was low, your route would be good. But this paper argues that q-error is a terrible predictor of whether you'll get stuck in traffic, especially when the GPS is really bad.

Instead, the authors found that the answer depends entirely on how big the mistake is. They discovered three different "regimes" (situations) where different rules apply.

The Three Regimes of Navigation

1. The "Small Mistake" Zone (The Tightrope)

When the GPS is mostly right, but slightly off.

Imagine you are walking on a tightrope between two buildings. If you take one tiny step to the left, you fall into Building A. If you take one tiny step to the right, you fall into Building B.

  • The Paper's Finding: In this situation, the most important thing isn't how accurate your GPS is, but how close you are to the edge.
  • The Metaphor: They call this the Condition Number (κ\kappa). It's like measuring the distance from your feet to the nearest railing.
    • If you are far from the edge, a small GPS error won't matter; you'll stay on the right path.
    • If you are standing right on the edge, even a tiny GPS error will make you fall into the wrong building.
  • Why it matters: In this zone, knowing where you are relative to the "switching point" predicts your failure better than knowing how wrong your GPS is.

2. The "Huge Mistake" Zone (The Dice Roll)

When the GPS is completely hallucinating.

Now imagine the GPS is so broken that it sends you to a random part of the city, far away from your actual destination. You aren't walking on a tightrope anymore; you are just guessing which building to enter.

  • The Paper's Finding: In this chaotic zone, your distance to the edge (Condition Number) doesn't matter anymore. Instead, what matters is how "risky" the city layout is for this specific trip.
  • The Metaphor: They call this ACS∞ (Average-Case Sub-optimality). Think of it as a "Difficulty Score" for the query.
    • Some queries are like a city with only one good road; even if you guess randomly, you might still get lucky.
    • Other queries are like a city with 100 roads, but 99 of them lead to a dead end or a traffic jam. If your GPS is broken, you are almost guaranteed to pick a bad road.
  • The Surprise: The authors tested this on real-world data and found that q-error was useless here (it couldn't predict anything). But their new "Difficulty Score" (ACS∞) successfully predicted which queries would fail. It's like saying, "This specific trip is inherently dangerous if your map is wrong," regardless of exactly how wrong the map is.

3. The "Worst-Case" Zone (The Nightmare)

When you want to be 100% safe.

This is the scenario where you assume the GPS will make the absolute worst possible mistake imaginable.

  • The Paper's Finding: This is known as MSO (Maximum Sub-optimality). It's the "worst-case scenario" metric that researchers have used before.
  • The Connection: The authors show that all three of these concepts (Condition Number, Difficulty Score, and Worst-Case) are actually just different ways of looking at the same underlying map. They are just weighting the "badness" of the roads differently:
    • Small errors: Focus on the nearest bad road.
    • Large errors: Focus on the average bad road.
    • Worst case: Focus on the most bad road.

The Big Takeaway

The paper solves a long-standing debate in the database world: "Does a lower q-error mean a better plan?"

The answer is: It depends.

  • If your estimation errors are tiny, q-error doesn't matter as much as your proximity to a decision boundary.
  • If your estimation errors are huge (which is where modern AI-based estimators often operate), q-error is almost useless. It tells you nothing about whether you'll get stuck in traffic.

Instead, for big errors, we need a new metric (ACS∞) that measures the inherent difficulty of the query itself. The authors proved this mathematically and tested it on real database software (PostgreSQL), showing that their new metric predicts real-world slowdowns much better than the old standard.

In short: You can't use a single ruler to measure everything. When the map is slightly off, you need to know how close you are to the cliff. When the map is totally broken, you need to know if the terrain itself is a minefield. The paper gives us the right tool for each job.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →