Functional Aggregate Queries with Additive Inequalities

Mahmoud Abo Khamis, Ryan R. Curtin, Benjamin Moseley, Hung Q. Ngo, XuanLong Nguyen, Dan Olteanu, Maximilian Schleich

Introduction

This paper introduces FAQ-AI, a framework for answering Functional Aggregate Queries that include additive inequalities (such as $x + y \le z$). By combining database theory with geometric data structures, the authors prove that these queries can be solved asymptotically faster than traditional join-based methods. This enables "in-database" machine learning for models like k-means and SVMs without ever materializing massive intermediate tables.

The Challenge of Inequality Joins

In both database systems and machine learning, we often need to compute aggregates over the results of a "join" — combining multiple tables based on shared variables. Standard Functional Aggregate Queries (FAQ) handle equality joins well, but many real-world applications require inequality joins (e.g., finding orders placed before a certain date or points within a certain distance).

Existing state-of-the-art algorithms like InsideOut or PANDA treat inequalities as "black-box" filters. This is inefficient because it fails to exploit the geometric structure of the inequalities. For a query involving a simple inequality like $a \le d$ across different tables, traditional methods might default to an $O(N^2)$ runtime. The authors aim to bridge this gap by creating algorithms that "understand" the geometry of inequalities to achieve much lower computational complexity.

The FAQ-AI Framework

The authors introduce several theoretical and algorithmic innovations to handle these complex queries:

1. Relaxed Tree Decompositions

Traditional tree decompositions require every "edge" (relationship) in a query to be contained within a single "bag" (node) of the tree. The authors relax this, allowing inequality relationships (called "ligaments") to be covered by the union of two adjacent bags. This leads to smaller "width" parameters, which directly translate to faster runtimes.

2. Geometric Integration

To solve the sub-problems created by these relaxed decompositions, the authors integrate Chazelle’s geometric data structures for semigroup range searching. This allows the algorithm to count or sum points in multi-dimensional ranges in polylogarithmic time. Essentially, an inequality join is treated as a range search problem in disguise.

3. New Complexity Measures: #subw

They define sharp submodular width (#subw) and its relaxed version. While "submodular width" was previously only useful for Boolean (True/False) queries, #subw extends these tight complexity bounds to counting queries and general semirings. The authors prove a new hierarchy of query hardness: $\text{subw} \le \text{\#subw} \le \text{fhtw}$.

4. The #PANDA Algorithm

They extend the PANDA algorithm (which uses "power-set" based data partitioning) to handle non-Boolean semirings, creating a more general tool for complex relational aggregates.

Applications in Machine Learning

The paper evaluates performance based on relational schemas and machine learning workloads. The authors mathematically reformulate the training steps for k-means clustering, Linear Support Vector Machines (SVM), and Huber loss regression as FAQ-AI queries.

A key insight is the ability to avoid the "Join Bomb." In relational ML, the join of several tables can be orders of magnitude larger than the input tables. FAQ-AI allows computing gradients or means needed for ML training directly from the input tables, achieving runtimes that are sub-linear relative to the size of the full join.

Key Results

  • Asymptotic Speedups: For a specific query $Q_2$ involving three relations and one inequality ($a \le d$), traditional methods take $O(N^2)$. This paper proves it can be done in $O(N^{1.5} \log N)$.
  • ML Efficiency: An iteration of the k-means algorithm or an SVM gradient update can be computed in time proportional to the "relaxed" width of the feature extraction query, which is often significantly faster than materializing the training dataset.
  • Unified Framework: The framework also recovers and explains the known linearithmic complexity of evaluating XML path queries (Core XPath).

Conclusion and Future Directions

While a theoretical breakthrough, the FAQ-AI framework currently has limitations:

  • Semiring Constraints: It supports "additive" inequalities but does not yet support non-polynomial loss functions like logistic or exponential loss.
  • Implementation Gap: The paper is a theoretical foundation; it does not provide a physical implementation in a database engine. Future work involves integrating these geometric data structures into a query optimizer to test against real-world SQL engines.
  • Hardness Proofs: Proving "matching" lower bounds for count queries with unbounded #subw remains an open problem.

Summary updated

BibTeX
@article{khamis2020functional,
  author = {Mahmoud Abo Khamis and Ryan R. Curtin and Benjamin Moseley and Hung Q. Ngo and XuanLong Nguyen and Dan Olteanu and Maximilian Schleich},
  title = {{Functional Aggregate Queries with Additive Inequalities}},
  journal = {ACM Trans. Database Syst.},
  year = {2020},
  doi = {10.1145/3426865},
}
Figure