Manuscript Offprint
arXiv:2610.39311Tight Asymptotic Bounds on the Size of Order Graphs
Abstract
Order graphs were introduced by Arroyuelo et al. (TODS 2024) as a generalization of the ring index, to support worst-case optimal joins on relations of arity while storing as few columns as possible: the index stores one column per edge, so its size is proportional to the number of edges of an order graph. It was known that the minimum number of edges lies between and , and the lower bound had been claimed to be 42 for . We first exhibit an order graph with only 40 edges for , and show that the proof of that lower bound holds only for unions of cycles, whereas order graphs can be smaller than the smallest set of cycles. We give a corrected statement and proof that holds for every order graph: there must be at least edges. This bound is 40 for , so our 40-edge graph is optimal. We then settle the asymptotic question: the minimum size is . This is obtained via an explicit construction, based on symmetric chain decompositions of the Boolean lattice, with at most edges. The upper bound is within a factor of the lower bound, and both numerically and asymptotically better than trie switching.
1 Introduction
Worst-case optimal joins and their space problem. A multijoin algorithm is worst-case optimal (wco) if it runs in time proportional to the AGM bound [3], the largest possible output of the query on databases of the given size. Classic multijoin algorithms that join two tables at a time are not wco, as they can produce intermediate results that are asymptotically larger than [3]. Since the first wco algorithm [6], Leapfrog TrieJoin (LTJ) [7] has become a reference wco algorithm because of its simplicity. Instead of joining tables pairwise, LTJ “binds” one join attribute at a time: at each step, every joined relation that contains the next attribute must be able to search the values of compatible with the attributes already bound. With classical prefix-based indexes (tries, B-trees), this requires the bound attributes to form a prefix of an indexed order, followed by . Supporting every binding order thus requires up to orders for a relation of arity , or the equivalent of tries with the trie switching technique on meta-tries [1, Lemma 7.8]. Since the tries have levels, they store in the worst case values for a table of tuples, or with trie switching. This is much more than the values needed to store the table in plain form.
The ring. The ring [2, 1] avoids this redundancy. It stores each attribute as a separate column, sorted by a stable re-sort of a “previous” one, which allows the rows of any column to be mapped to those of the next efficiently without pointers. For , a single ring with columns supports LTJ in wco time over every binding order, using essentially the same values of storage required anyway to store the table in plain form. The key property is that, regarded cyclically and in both directions, a sequence of the attributes contains every possible binding sequence: any subset of already bound attributes can be extended to contain the new attribute to bind, either backwards or forwards. The ring exploits this fact by always maintaining a range of some column that represents the current node of any of the tries along the LTJ algorithm.
From rings to order graphs. For a single ring no longer suffices; for example with attributes , the circular string does not contain the substring (nor ); we need two rings like and to do the trick. The natural question is: how many rings are needed with attributes? It was proved that rings, thereby using space, were sufficient to support LTJ [1], which puts the ring in the same asymptotic family of trie switching.
Arroyuelo et al. [1] then generalized sets of rings to order graphs: directed graphs whose nodes are attribute orders, where an edge labeled by attribute goes from an order to the order obtained by stably re-sorting by (that is, by moving to the front). For that edge, the index stores the column of the table, in the order that results from lexicographically sorting the table rows with the attributes reordered as (several edges may be labeled , so the index will store several copies of column , with orders given by different s). To support LTJ in wco time, an order graph must be complete: for every set of bound attributes and every next attribute , the graph must contain a path labeled by with at one end [1, Thm. 7.4]. Since the index stores a column ( values) per graph edge, the central combinatorial question is:
What is the minimum number of edges of a complete order graph of dimension ?
A set of rings is an order graph formed by various length- cycles, but complete order graphs can be strictly smaller: for , a single cycle of length 20 is complete, whereas 5 rings (25 edges) are needed if only rings of length are used.
The lower bound. The minimum size of a complete order graph was shown to lie between [1, Thm. 7.9] and (from the rings). Exhaustive combinatorial exploration, mostly restricted to cycles and sets of rings, found that the minimal complete order graphs for matched the numerical lower bound [1, Thm. 7.9], including a cyclic graph of size 42 for . These numbers are much smaller than the sizes of trie switching, which backed the conjecture that the actual size is closer to than to the of trie switching, and thus order graphs are indeed superior. But the conjecture remained unproved.
-
A correct lower bound (Theorem 6). Any complete order graph has at least edges. The key is to charge each requirement to the last edge of its “witness path”, which determines the whole label sequence regardless of branching. This coincides with the previous bounds for [1] except for , where it gives exactly 40. Hence our graph of Figure 1 is minimal. We also give a proof valid for arbitrary graphs of the unidirectional bound (where can only occur after , useful for restricted classes of rings [1]). Both lower bounds are still .
-
A matching upper bound (Theorem 10). An explicit construction, computable in time , with at most edges, which is complete even with the unidirectional restriction. This is obtained by means of symmetric chain decompositions [5]. Consequently, the minimum size of a complete order graph in dimension is in both the bidirectional and the unidirectional case, which closes the question in the asymptotic sense (Corollary 12) and establishes the superiority over trie switching. The ratio between our upper and lower bounds is at most in the bidirectional model and at most in the unidirectional one.
Organization. Section 2 fixes notation. Section 3 proves the lower bounds and explains the flaw in the original argument. Section 4 gives the upper-bound construction. Section 5 derives the asymptotics and compares with known values. Section 6 discusses remaining gaps and concludes.
2 Basic Concepts
Let the attribute set be . An order is a permutation of . We write for the subsequence , also used as a set when convenient, and for the position of in . For , is the order obtained by moving to the front of , keeping the relative order of the other attributes.
Definition 1 ([1, Def. 7.1]). An order graph of dimension is a labeled directed graph where is a set of orders and an edge from to with label may exist only if .
Note that, in an order graph, the source and the label determine the target; we write edges as , always with (self-loops are useless). The size of is .
Definition 2. A requirement is a pair , with and . An order graph serves if it has a directed path with edges whose labels are exactly , and where the edge labeled is the first or the last one. In the unidirectional model, the edge labeled must be the last one in the path. The requirement has level and set , so .
Note that there are exactly requirements of level m, namely m for each m-subset U of [d]. To support LTJ, an order graph must serve them all.
Definition 3 ([1, Def. 7.2]). is complete if it serves every possible requirement .
Observation 4 (implicit in [1, Lemma 7.6]). If a path with distinct labels ends at node , then .
Proof. By induction on . The last edge moves to the front and shifts , which by induction occupied the first positions and differ from , one position to the right.
3 Lower Bounds
We first note that there is exactly one label sequence per edge and length.
Lemma 5. Let and . If a path with m edges and distinct labels ends with e, then its label sequence is exactly , and .
Proof. The first edges form a path with distinct labels ending at , so by Observation 4 their labels are . Since differs from all of them, , that is, . Thus, the -sequence that arrives at the target node of is .
This implies that every edge and every together determine a unique set
and therefore a path with edges ending with can serve only two requirements of level , both with set :
• , with x = a last, and
• , with first.
For m = 1 both coincide with .
Theorem 6 (correcting [1, Thm. 7.9]). Let be a complete order graph of dimension , and let . Then, for every ,
In particular, .
Proof. Fix . For each requirement of level , choose a witness path as in Definition 2 and charge the requirement to the last edge of the path, which belongs to by Lemma 5. By the same lemma, an edge is charged at most two requirements, both with set . Therefore, the requirements with a given set are charged to at least distinct edges , all with . Since is determined by , edges charged for different sets are distinct. Summing over the sets yields the bound.
Theorem 7 (unidirectional case). If is complete in the unidirectional model, then for every , . Hence .
Proof. As before, but now an edge is charged at most one requirement of each level.
Note that the proofs do not depend on the shape of ; in particular they need neither the reduction to in-degree 1 [1, Lemma 7.7] nor any assumption on cycles.
3.1 What went wrong in the original proof
By the symmetry , each inner term of the original bound equals the term of Theorem 6 with , so the only numerical difference is the final rounding per attribute. The original argument, however, fails in two steps.
-
It counts per -set , assuming that each occurrence of as a path serves at most two attributes , one at each end. With branching this fails: if and has outgoing edges for various , a single occurrence of serves all those requirements . Theorem 6 counts instead per set and charges it to the last edge, which determines the whole sequence (Lemma 5) regardless of branching.
-
It rounds per attribute, as ; this is exactly what turns 40 into 42 for d = 6.
The value of the unidirectional bound [1] was correct; Theorem 7 provides a proof valid for arbitrary order graphs. For unions of cycles, however, the original argument is valid. There, the only paths of edges containing a window of consecutive edges extend it by the edge just before or just after it, so each window with distinct labels serves at most two requirements with . Every -set must therefore appear in at least windows. Each edge labeled belongs to at most windows, so there are at least edges labeled , for each . For and this gives .
Corollary 8. The minimum size of a complete order graph of dimension 6 is exactly 40.
Proof. , attained at , and the graph of Figure 1 is complete with 40 edges, as can be checked directly (we also verified it mechanically, see Appendix A).
For all other the corrected bound has the same value as in Arroyuelo et al. [1]; see Table 1. In particular, the exhaustive searches done in that paper remain conclusive for . The next difference with previous work occurs at (760 versus our 756).
4 An Upper Bound of
We use a symmetric chain decomposition (SCD) of the Boolean lattice [4]. The parenthesis-matching construction of Greene and Kleitman [5] produces it in time.
Definition 9. An SCD of is a partition of the subsets of into chains , where contains exactly one set of each size in , being the size of its smallest set, and each other set of contains the previous one.
Note that exactly one chain, the one containing and , has ; in general, there are chains with , for , since every chain with meets level exactly once. Let be the number of sets in ; then it follows that .
We extend each chain to an order : first the elements of the smallest set of (in any order), then the element added by each subsequent set, and finally the remaining elements. Thus every satisfies . Let and .

Figure 1: A complete order graph for with 40 edges, which is optimal by Corollary 8. Each node shows its order and each edge its label. The cycle (gray nodes, thick edges) has labels 6, 5, 2, 1, 4; attribute 3 never occurs on it, so it stays last in every cycle order. Every other order follows from its parent by moving the edge label to the front. Every node has in-degree 1, so the graph is a single “hairy” cycle in the sense of Arroyuelo et al. [1, Lemma 7.7].
The construction. For each , let and , and add the following edges:
- History. A path with edges, starting at , with labels . By induction, the node reached after edges is
so . No edge is a self-loop, because its label is the last element of .
- Hairs. The edges for .
The order graph is the union of all these edges, where repeated edges are counted once.
Theorem 10. is complete (even in the unidirectional model), can be built in time, and
Proof. Completeness. For we need an edge labeled , for every . The chain containing has , and at its order there are hairs labeled , while the last edge of its history is labeled .
Let now with , and let be the unique chain containing . Then , so , and . The last edges of have the distinct labels and end at . Since , we have , so the hair exists. Together they form a path with edges, labels , and last.
Size. Chain contributes history edges and hairs. Since , summing over the chains gives .
Time. The SCD and the orders are obtained in time per set of the lattice, and each chain contributes edges.
Example. Let d = 4. The Greene-Kleitman SCD and the resulting orders are:
| chain | ||
|---|---|---|
| 1234 | [1,3] | |
| 2341 | [1,3] | |
| 3142 | [1,3] | |
| 4123 | [1,3] | |
| 2413 | [2,2] | |
| 3412 | [2,2] |
The histories of 1234, 2341, 4123, and 3412 all lie on the ring , whose consecutive orders are rotations of each other. The history of 3142 closes a second ring, because its hair labeled 2 leads back to the start 2314 of its history. The bound of Theorem 10 is 34 and the construction produces 32 edges (the bound overcounts 2 edges in the chain that contains and ), but repeated edges reduce to 21 edges (Figure 2).
Consider and . The chain containing is , with , so . The witness consists of the last two edges of the history of 3142, namely , followed by the hair . Its labels are , with last.

Figure 2: The graph of our example, with 21 edges. Gray nodes are the chain orders ; thick edges form the ring shared by four histories. Leaves reached by two edges (1342 and 3241) are drawn twice, which does not change the edge count. The four edges and are redundant: the paths and already provide those histories, and removing them leaves a complete order graph with 17 edges.
5 Asymptotics and Exact Values
We use the central binomial estimate from Stirling's approximation, and write . By Pascal's triangle rule, .
Lemma 11. For every ,
Consequently,
Proof. Since , we have , and the maximum of over is . The value of is its definition. The bound on follows from Theorem 10 and . The asymptotic forms follow from and .
Corollary 12. The minimum size of a complete order graph of dimension is , both in the bidirectional and in the unidirectional model. More precisely, for every ,
This improves the previous upper bound of [1] by a factor .
| d | Bidirectional | Unidirectional | Formal constructions | |||||
|---|---|---|---|---|---|---|---|---|
| [1, Thm. 7.9] | LB_{bi} | best known | LB_{uni} | best known | Thm. 10 | |||
| 3 | 3 | 3 | 3 | 6 | 6 | 6 | 14 | 12 |
| 4 | 8 | 8 | 8 | 12 | 15 | 21 | 34 | 32 |
| 5 | 20 | 20 | 20 | 30 | 33 | 52 | 72 | 80 |
| 6 | 42 | 40 | 40 | 60 | 66* | 132 | 164 | 192 |
| 7 | 70 | 70 | 83* | 140 | 162* | 300 | 338 | 448 |
| 8 | 168 | 168 | 200* | 280 | 360* | 697 | 746 | 1024 |
Table 1: Lower bounds, best known sizes, and formal constructions. “Best known” is taken from Table 6 of [1], except for bidirectional, which is our graph of Figure 1; an asterisk marks values not obtained by exhaustive search. is the actual size of our construction and the next column its bound. The last column is the trie-switching size [1, Lemma 7.8].
Proof. By Lemma 11, , and because . The unidirectional case is identical, with .
Table 1 compares values for small . The construction does not compete with the solutions found by computational search [1] for ; its interest is asymptotic. Still, it is smaller than the trie-switching bound [1, Lemma 7.8] for every .
6 Conclusions and Open Problems
We have shown that the minimum number of columns of an order index supporting worst-case optimal joins on a relation of arity is . This closes the gap between the and bounds known so far and shows that order graphs can use asymptotically less space than trie switching. On the way, we found a complete order graph for with 40 edges, smaller than any union of cycles, which showed that the previous lower bound argument applied only to unions of cycles. We then gave a lower bound valid for every order graph, which proves that this graph is optimal. Our upper bound is an explicit construction based on symmetric chain decompositions of the Boolean lattice. It uses only the unidirectional model, so it also settles this case asymptotically. The remaining gaps are constant factors: asymptotically, the upper and lower bounds differ by a factor of 4 in the bidirectional model and 2 in the unidirectional one. In broad terms, an order index stores times more data than the relation itself, against for classical indexes over all orders and with trie switching on meta-tries. This considerably extends our understanding of order graphs and confirms that they can make worst-case optimal joins affordable for moderate arities. We finish with some open problems.
Sharing histories (a factor of 2). Half of the cost of is spent on histories, paid separately for each . Our example shows how they can often be shared. In general, suppose that with and . Then the edge , which is a hair of whenever , preceded by the history of , is already a valid history for , and can be dropped. The histories then form a forest rooted at the chains whose histories cannot be shared. After removing redundant edges as in [1, Lemma 7.6], each tree can be closed into a hairy cycle of the same size, as in the proof of [1, Lemma 7.7].
Open problem 1. Is there an SCD of , and extensions of its chains, forming an arborescence in the sense above except for roots? Then the hairs, , would dominate the size, yielding complete order graphs with edges. This would settle the unidirectional case save for lower-order terms.
Using extensions in both directions (the other factor of 2). To reach , almost every edge must serve both requirements of , at every central level . In , hairs serve only requirements in one direction.
Open problem 2. Construct complete order graphs with edges, or improve the lower bound by showing that the history constraints prevent a constant fraction of the edges from serving both ends.
Rings. The bound of [1, Lemma 6.8] gives rings of length , while the best known upper bound is rings.
Open problem 3. Is there a family of cyclic orders of such that every pair with appears, in some of them, as an arc with set and at one end? If so, sets of rings also reach edges.
Paths with repeated labels. Definition 2 asks for paths with edges, hence without repeated labels. The order index could also use longer paths that repeat labels, by restricting again by an attribute that is already bound, at some cost in query time [1]. Exhaustive searches found no case where this yields smaller complete order graphs [1]. Observation 4 generalizes to this case: if a path ends at , then starts with the distinct labels of the path, sorted by their last occurrence, most recent first. Hence, if occurs only as the last label of the path, the last edge determines the set , and Theorem 7 still holds. When is the first label but occurs again later in the path, however, need not be at position of . Then a single edge might serve more than two requirements with the same set, and the proof of Theorem 6 no longer applies.
Open problem 4. Does Theorem 6 hold for bidirectional order graphs when paths may repeat labels? More generally, can repeated labels ever reduce the minimum size of a complete order graph?
References
[1] Diego Arroyuelo, Adrián Gómez-Brandón, Aidan Hogan, Gonzalo Navarro, Juan L. Reutter, Javiel Rojas-Ledesma, and Adrián Soto. The Ring: Worst-case optimal joins in graph databases using (almost) no extra space. ACM Transactions on Database Systems, 49(2):article 5, 2024.
[2] Diego Arroyuelo, Aidan Hogan, Gonzalo Navarro, Juan Reutter, Javiel Rojas-Ledesma, and Adrián Soto. Worst-case optimal graph joins in almost no space. In Proc. 47th ACM International Conference on Management of Data (SIGMOD), pages 102–114, 2021.
[3] Albert Atserias, Martin Grohe, and Dániel Marx. Size bounds and query plans for relational joins. SIAM Journal on Computing, 42(4):1737–1767, 2013.
[4] N. G. de Bruijn, C. van Ebbenhorst Tengbergen, and D. Kruyswijk. On the set of divisors of a number. Nieuw Archief voor Wiskunde (2), 23:191–193, 1951.
[5] Curtis Greene and Daniel J. Kleitman. Strong versions of Sperner’s theorem. Journal of Combinatorial Theory, Series A, 20(1):80–88, 1976.
[6] Hung Q. Ngo, Ely Porat, Christopher Ré, and Atri Rudra. Worst-case optimal join algorithms. Journal of the ACM, 65(3):16:1–16:40, 2018.
[7] Todd L. Veldhuizen. Triejoin: A simple, worst-case optimal join algorithm. In Proc. 17th International Conference on Database Theory (ICDT), pages 96–106, 2014.
A Mechanical Verification
We implemented a checker for Definition 3, which computes, for each node, the longest path reaching it whose labels form a reversed prefix of its order, and then the requirements served by each edge according to Lemma 5. As sanity checks, it confirms the facts known from [1]: one ring is complete for , one ring is not enough for , and the two rings with orders 1234 and 1324 are complete. With it we verified that
-
the graph of Figure 1 is complete with 40 edges;
-
is complete for , with the sizes of Table 1 (1443 edges for );
-
the 17-edge graph of Figure 2 is complete.
We did not search for optimal graphs for fixed .