arXiv:2608.26775cs.DBAug 2026

Manuscript Offprint

arXiv:2608.26775

Size Bounds for CQs Under Acyclic Constraints

Stefan Mengel, Andrei Romashchenko

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

We study size bounds for conjunctive query (CQ) results which in recent years have played a crucial role in database theory. In particular, we compare the so-called entropic bound which is known to be asymptotically tight but not known to be computable, and its computable relaxation called the polymatroid bound, which is generally not tight. We focus here on conjunctive queries under acyclic functional dependencies. These queries are known to be well-behaved in the sense that, in the case without projections, both bounds coincide. We show that this picture changes when projections are allowed: in this case, even for acyclic functional dependencies, there is in general a polynomial gap between the two bounds. We complement this negative result by showing a special case for which the polymatroid bound is tight under acyclic functional dependencies and projections that is characterized by the position of the output variables in a topological order of the query variables.

2012 ACM Subject Classification Theory of computation → Database theory; Mathematics of computing → Information theory

Keywords and phrases database theory, conjunctive queries, query size bounds, polymatroids, information theory

1 Introduction

Computing bounds on the size of query results is crucial in databases. In a database systems context, this task is called cardinality estimation and plays an important part in query optimization, see e.g. [23, 17]. There are different types of heuristics that solve it in practical systems with varying quality, and they have a great influence on query evaluation runtimes, see e.g. [17, 30]. In contrast to these heuristic estimates in systems work, in database theory the focus is on bounds for conjunctive queries that are provably correct. The idea is to compute bounds on the output size based on more or less detailed statistics of the input database. These statistics generally include the cardinalities of the input tables, but also more refined measures like degree information and functional dependencies (FDs).

Size bounds for query answers are not only intriguing by themselves, but have also played a crucial role for the development of algorithms. For example, the AGM-bound [4] has lead to a revolution in join evaluation by the development of worst-case optimal join algorithms [22, 21], i.e. algorithms whose runtime is linear in the size of the biggest possible query answer. The link between bounds and algorithms is even more direct when taking into account functional dependencies in the data or their generalization degree constraints: given statistics on the input database, the so-called polymatroid bound for the output size can be computed by solving a linear program. The solution to this program can then be translated into a sequence of operations that an algorithm, called PANDA [15], uses to evaluate the query. The computation of the bound thus guides the algorithm whose runtime turns out to be quasi-linear in the bound.

So to speed up the evaluation of queries, it is important that the runtime bounds are as small as possible while still being correct. For join queries with only cardinality constraints on the input database, it is known that the AGM-bound is tight [4], so for every query Q and every set of cardinality constraints, there is a database D satisfying the cardinality constraints such that the size of output size Q(D)Q(D) is up to a constant factor equal to the AGM-bound.

Size Bounds for CQs Under Acyclic Constraints

This is the underlying reason why we know that the worst-case optimal algorithms, whose runtime is proportional to the AGM-bound, are in fact worst-case optimal.

Once we add more refined constraints, the situation becomes less satisfying: when considering degree statistics and, as an important special case, functional dependencies for the computation of upper bounds, we know that the so-called entropic bound is a tight bound on the worst-case size of query results [15, 25]. While this sounds promising, this result comes with a catch: it is not known if the entropic bound is even computable! This is due to deep questions in information theory related to the lack in good understanding of the so-called entropic cone [27]. While there has been progress in that direction over the last few years, see e.g. [31, 18, 19, 9, 20, 8, 16] and the surveys in [29, 28, 7], fully understanding the situation seems to be far off. In database theory, one consequence of the resulting limited understanding of the entropic bound is that, in contrast to other bounds, so far it does not seem to lead to an algorithm for query evaluation.

One way of side-stepping this problem is considering looser bounds with better algorithmic properties. This is in fact what the already mentioned polymatroid bound does. It is an approximation of the entropic bound that can be computed with linear programming and leads to a fast evaluation algorithm for conjunctive queries, the PANDA algorithm. However, it is known that the polymatroid bound is in general not tight, i.e. the size bounds for query results that it gives can be off by a polynomial factor, even for the restricted case of join queries with functional dependencies. As a consequence, the PANDA algorithm is generally not worst-case optimal and there is in fact no known worst-case optimal algorithm in the setting. As a result, the complexity of conjunctive queries in the presence of FDs and more general degree constraints is less well understood than with only cardinality constraints. Moreover, unless there are breakthroughs in information theory, we seem to be stuck with this unsatisfying situation.

However, while in general the situation for bounds on query results under degree constraints might be difficult to understand, we can still aim to better understand it for restricted cases. For example, size bounds are better understood for the case in which all degree constraints are simple, i.e. the dependency is only on single attributes instead of sets [11, 10, 1, 25]. Another class of constraints that has attracted considerable interest is that of acyclic degree constraints. Roughly speaking, these are sets of constraints in which dependencies can only appear in a specific direction (see Section 2 for a formal definition). These constraints were introduced in [21] where it was shown that the entropic bound and the polymatroid bound coincide when restricted to acyclic degree constraints. This also results in worst-case optimal algorithms for join evaluation [21, 6]. Moreover, for this class of constraints there are efficient sampling algorithms [26, 6].

So far, the above positive results have only been shown for queries without any projections, i.e. all variables in the query are output variables. In practice however, projection is very common. After all, users might often be in a situation in which they do not care about some of the attributes in tables of a database. For example, when studying a large corpus of SPARQL queries, which is more general than what we study here, projection was found in 14.98% of all queries [5]. From a more theoretical perspective, projection is useful to materialize so-called bags in tree decomposition based approaches [12, 13, 15]. So studying the effect of projections on size bounds is certainly worthwhile. Concretely, the question we answer here is the following: do the entropic bound and the polymatroid bound for conjunctive queries with acyclic degree constraints still coincide for queries with projections?

We answer this question in the negative by constructing a query with acyclic functional dependencies for which the polymatroid bound exceeds the entropic bound by a polynomial factor. Consequently, the polymatroid bound is not tight for such queries, and existing algorithms are not worst-case optimal. This is in contrast to the setting without projections.

Our way of approaching the problem is as follows: we start with a known query with functional dependencies for which the polymatroid bound is known to be not tight from [14, 25]. The functional dependencies for this query are highly cyclic, so it does not answer our question directly. The key ingredient of our construction is then that we show of way of “untangling” the functional dependencies. To this end, for every variable involved in FDs that violate acyclicity, we break the cycles by adding a new variable that takes its role in the FDs. Doing this systematically and adding some more FDs between old and new variables, leads to a new query with a new set of FDs that are acyclic now. Our result then follows by showing that for the example query from [15, 25], this construction changes neither the entropic bound nor the polymatroid bound.

We complement these negative findings by showing that if in a query with acyclic FDs the output variables come “before” the projected variables in a well-defined sense, then the entropic bound and the polymatroid bound coincide.