Efficient Algorithms for Cardinality Estimation and Conjunctive Query Evaluation With Simple Degree Constraints

Sungjin Im, Benjamin Moseley, Hung Q. Ngo, Kirk Pruhs · DOI

Abstract

This paper presents the first polynomial-time algorithms for computing the polymatroid bound—the tightest known robust upper bound for database query sizes—specifically for "simple" degree constraints. By reducing an exponentially large optimization problem to a standard network flow problem, the authors enable faster cardinality estimation and more efficient query evaluation within the PANDA framework.

Introduction

In database systems, query optimizers must estimate the size of intermediate join results to select efficient execution plans. Traditional selectivity-based estimators often fail on real-world data due to independence assumptions. Information-theoretic bounds, such as the AGM and polymatroid bounds, provide mathematical guarantees on maximum output size given degree constraints (e.g., "one value of attribute A appears in at most 10 rows"). However, computing the polymatroid bound for general constraints is typically intractable, requiring the solution of a Linear Program (LP) with an exponential number of variables. This paper addresses the case of simple degree constraints (where the left-hand side has at most one variable), which are common in practice but previously lacked an efficient solution.

Algorithmic Framework

The authors employ several theoretical transformations to move from exponential complexity to polynomial tractability:

  1. LP Projection and Dualization: The standard LP for the polymatroid bound is simplified by taking its dual and projecting the feasible region onto a smaller space.
  2. Network Flow Reduction: For simple constraints, the complex hypergraph flow problem is reformulated as a series of min-cost network flow problems on a standard directed graph.
  3. Constructive Proof Sequences: The authors provide an algorithm to generate "proof sequences"—Shannon-type inequalities justifying the bound—in polynomial time.
Theoretical transformations from exponential to polynomial size.

Key Insights and Tractability

The research identifies "simple degree constraints" as a critical boundary for tractability. The authors prove that adding even minor complexity, such as combining simple constraints with acyclic ones or allowing two variables on the left-hand side, renders the problem NP-hard.

The most elegant insight is the realization that simple constraints allow a "hypergraph flow" (where flow can enter/leave multiple nodes at once via submodularity) to be modeled as a standard graph flow. This is illustrated through auxiliary graph constructions that map the constraints to a lattice structure, enabling the use of efficient flow algorithms.

Lattice structure representing the auxiliary graph construction for a running example.

Results

  • Efficiency: The polymatroid bound for $k$ simple constraints over $n$ variables can now be computed in polynomial time.
  • Proof Length: The authors can generate a proof sequence of length $O(k^2n^2 + kn^3)$, a massive improvement over previous methods that could only guarantee exponential-length sequences.
  • The Flow Bound: A new, tractable relaxation called the flow bound is introduced. It is computable in polynomial time for any set of degree constraints and is proven to be strictly tighter than the previously known chain bound.

Conclusion

This work provides a robust theoretical foundation for using degree constraints in query optimization. While general constraints remain a challenge, the polynomial-time algorithms for simple constraints and the introduction of the flow bound offer immediate practical utility. Future work will focus on identifying other tractable constraint classes and optimizing the variable permutations required for the flow bound.

Summary updated

BibTeX
@article{im2025efficient,
  author = {Sungjin Im and Benjamin Moseley and Hung Q. Ngo and Kirk Pruhs},
  title = {{Efficient Algorithms for Cardinality Estimation and Conjunctive Query Evaluation With Simple Degree Constraints}},
  journal = {Proc. ACM Manag. Data},
  year = {2025},
  doi = {10.1145/3725233},
}
Figure