On Functional Aggregate Queries with Additive Inequalities.

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

Abstract

Motivated by fundamental applications in databases and relational machine learning, we formulate and study the problem of answering functional aggregate queries (FAQ) in which some of the input factors are defined by a collection of additive inequalities between variables. We refer to these queries as FAQ-AI for short. To answer FAQ-AI in the Boolean semiring, we define relaxed tree decompositions and relaxed submodular and fractional hypertree width parameters. We show that an extension of the InsideOut algorithm using Chazelle's geometric data structure for solving the semigroup range search problem can answer Boolean FAQ-AI in time given by these new width parameters. This new algorithm achieves lower complexity than known solutions for FAQ-AI. It also recovers some known results in database query answering. Our second contribution is a relaxation of the set of polymatroids that gives rise to the counting version of the submodular width, denoted by #subw. This new width is sandwiched between the submodular and the fractional hypertree widths. Any FAQ and FAQ-AI over one semiring can be answered in time proportional to #subw and respectively to the relaxed version of #subw. We present three applications of our FAQ-AI framework to relational machine learning: k-means clustering, training linear support vector machines, and training models using non-polynomial loss. These optimization problems can be solved over a database asymptotically faster than computing the join of the database relations.

Introduction

In modern data science, machine learning models are frequently trained on data residing in relational databases. The traditional approach involves an "extract-transform-load" (ETL) pipeline where tables are joined into a single flat file before training. However, this join operation is often the primary bottleneck, as the resulting table can be exponentially larger than the input relations.

"In-Database Learning" aims to mitigate this by pushing aggregation operations through the join, avoiding the materialization of the full join result. While effective for simple joins, these methods often struggle with queries involving additive inequalities (e.g., temporal or spatial constraints). Such inequalities are critical for many ML tasks, such as distance calculations in k-means or hinge loss in SVMs. This paper introduces FAQ-AI, a framework designed to handle these constraints efficiently by leveraging geometric data structures and novel structural parameters.

Methodology: The FAQ-AI Framework

The authors extend the Functional Aggregate Query (FAQ) framework to incorporate Additive Inequalities (AI). The core of their approach lies in three technical innovations:

1. Relaxed Tree Decompositions

Standard query optimization uses tree decompositions where every relationship (edge) must be contained within a single "bag." The FAQ-AI framework introduces relaxed tree decompositions. Here, standard relations (the "skeleton") must still be contained in individual bags, but inequalities (the "ligaments") can be covered by the union of two adjacent bags. This relaxation allows for significantly smaller bag sizes, which directly translates to lower computational complexity.

2. Geometric Range Searching

To process the "ligament" inequalities efficiently, the authors integrate Chazelle’s geometric data structures for semigroup range searching. Instead of scanning the entire dataset to satisfy inequality constraints, the algorithm can count or sum values in polylogarithmic time. This integration allows the extended InsideOut algorithm to achieve superior performance on Boolean FAQ-AI queries.

3. Sharp Submodular Width (#subw)

For non-Boolean tasks, such as counting or summing over arbitrary semirings, the authors introduce a new width parameter: #subw. This parameter is "sandwiched" between the submodular width and the fractional hypertree width, providing a more precise complexity measure for counting queries. They also develop #PANDA, a variant of the PANDA algorithm, to meet the theoretical complexity bounds defined by this new parameter.

Applications in Relational Machine Learning

The FAQ-AI framework is particularly powerful for training ML models directly over relational data. The paper demonstrates that several optimization problems can be solved asymptotically faster than the time required to compute the underlying join:

  • k-means Clustering: Distance-based assignments can be formulated as FAQ-AI queries.
  • Linear Support Vector Machines (SVMs): The hinge loss function, which involves inequalities, fits naturally into the framework.
  • Non-polynomial Loss Functions: The framework supports Huber, Hinge, and Scalene loss functions, which are common in robust regression and classification.

For example, the authors show that certain queries requiring $O(N^2)$ time in traditional systems can be reduced to $O(N^{1.5} \log N)$ using their techniques.

Conclusion and Future Directions

The FAQ-AI framework provides a rigorous theoretical foundation for efficient in-database learning with inequalities. By treating inequalities as geometric "ligaments" rather than black-box constraints, the authors unlock significant asymptotic speedups.

Future work includes extending the framework to support logistic or exponential loss functions, which are currently not representable as FAQ-AI. Additionally, while the theoretical upper bounds are promising, practical implementation within a production database engine is necessary to evaluate the real-world impact of the constant factors associated with geometric data structures. Proving matching lower bounds for counting queries also remains an open theoretical challenge.

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 = {{On Functional Aggregate Queries with Additive Inequalities.}},
  journal = {ACM Trans. Database Syst.},
  year = {2020},
  doi = {10.1145/3426865},
}
Figure