Selectivity Estimation for Linear Queries via Online Learning

Fangzhu Shen, Debmalya Panigrahi, Sudeepa RoyarXiv 2026

TL;DR

This paper introduces a distribution-free online learning framework for database selectivity estimation, moving beyond traditional static assumptions to handle arbitrarily changing data and query workloads. By analyzing performance through the lens of regret, the authors establish nearly tight upper and lower bounds for linear queries across both static and dynamic database settings under standard loss functions.

What Problem Does This Paper Address?

Selectivity estimation—predicting the fraction of rows a query will return—is a core component of database query optimizers, enabling them to choose efficient execution plans. Recently, machine learning approaches have shown great empirical success in this domain. However, their theoretical guarantees heavily rely on traditional passive learning frameworks (like PAC learning), which assume that the underlying database is static and queries follow a fixed, stationary distribution.

In the real world, database environments are highly dynamic: data is continuously inserted, updated, and deleted, and query patterns shift unpredictably. When these workloads drift, static models degrade, requiring expensive retraining. This paper tackles the challenge of providing rigorous, worst-case theoretical guarantees for selectivity estimation in fully dynamic, distribution-free environments where both data and queries can change adversarially over time.

Methods

The authors frame selectivity estimation as an online learning game played over $T$ rounds. In each round, a query arrives, the learner predicts its selectivity, the true selectivity is revealed, and the learner incurs a loss based on its prediction error. Performance is evaluated using regret—the difference between the algorithm's cumulative loss and that of the best fixed database state chosen in hindsight.

The paper investigates two standard loss functions (squared loss and absolute loss) across two database settings:

  1. Static Databases: The database vector is fixed but unknown, while queries change arbitrarily. The authors propose the Sequential Maximum Entropy (SeqMaxEnt) algorithm, which maintains a feasible space of candidate databases consistent with prior observations and predicts using the maximum entropy vector.
  2. Dynamic Databases: Both data and queries change arbitrarily across rounds. For squared loss, they leverage the Exponentially Weighted Online Optimization (EWOO) algorithm. For absolute loss, they use the Follow-the-Regularized-Leader (FTRL) framework, instantiating it with a squared-$\ell_2$ regularizer for point queries and a negative-entropy regularizer for general linear queries.

Datasets

None used. This is a purely theoretical paper focused on establishing mathematical upper and lower bounds for regret. The authors note that empirical evaluation on real-world queries and databases is an important direction for future work.

Key Insights and Ideas

  • The Power of Maximum Entropy: In a static database, simply picking any valid database vector consistent with previous queries yields a trivial cumulative loss bound of $k-1$ (where $k$ is the domain support size). By deliberately choosing the maximum entropy vector, SeqMaxEnt ensures that if the algorithm suffers a large loss, the true database must be "far" away in a KL-divergence sense. This guarantees significant mathematical progress toward identifying the true database, dropping the regret to $O(\log k)$ for squared loss.
  • Polynomial Separation of Loss Functions: A fascinating finding is that the choice of loss function fundamentally changes the difficulty of the problem. Squared loss and absolute loss exhibit a polynomial separation in their dominant parameters ($\log k$ vs $\sqrt{k}$ in static settings; $\log T$ vs $\sqrt{T}$ in dynamic settings).
  • Hadamard Matrix Encoding: To prove the lower bound for absolute loss in static databases, the authors creatively use a normalized Hadamard matrix to encode multiple independent random variables into a single, fixed database vector. This forces the learner to effectively guess blindly each round, proving a fundamental hardness limit of $\Omega(\sqrt{k/\log k})$.

Key Results

The paper provides a comprehensive taxonomy of tight or nearly tight regret bounds across different query classes (point, range, subset, and linear queries):

  • Static Databases: SeqMaxEnt achieves an upper bound of $O(\log k)$ for squared loss and $O(\sqrt{k \log k})$ for absolute loss on linear queries, matching the proven lower bounds up to logarithmic factors.
Table 1. Regret bounds for selectivity estimation on static databases. 𝑘is the support size of the domain. Each row reports upper and lower regret bounds holding for the indicated query classes.
  • Dynamic Databases: The EWOO algorithm achieves $O(k \log T)$ regret under squared loss against a lower bound of $\Omega(\log T)$. Under absolute loss, FTRL variants achieve optimal bounds of $O(\sqrt{T})$ for point queries and $O(\sqrt{T \log k})$ for subset/linear queries.
Table 2: Regret bounds for selectivity estimation on dynamic databases.

Limitations and Future Work

The authors highlight several open problems and promising directions:

  1. Closing the Gap: In the dynamic setting under squared loss, there remains a gap between the $\Omega(\log T)$ lower bound and the $O(k \log T)$ upper bound that needs to be tightened.
  2. Range Queries under Absolute Loss: Determining the exact optimal regret for range queries under absolute loss remains open for both static and dynamic settings.
  3. Richer Query Classes: The current framework is limited to linear queries. Extending these guarantees to more complex scenarios, such as join queries or queries with multiple predicates, is a crucial next step.
  4. Empirical Validation: Translating these online algorithms into practical database systems to evaluate how these theoretical worst-case guarantees hold up against real-world data and workload drifts.

Summary updated

BibTeX
@misc{shen2026selectivity,
  author = {Fangzhu Shen and Debmalya Panigrahi and Sudeepa Roy},
  title = {{Selectivity Estimation for Linear Queries via Online Learning}},
  year = {2026},
  eprint = {2607.02895},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.02895},
}
Figure