HOMES: A Higher-Order Mapping Evaluation System

Huy Vu, Michael BenediktPVLDB 2011

Introduction

HOMES (Higher-Order Mapping Evaluation System) is a research prototype designed to bridge the gap between functional programming abstractions and relational database performance. In traditional database systems, a sharp divide exists between data queries (SQL) and the logic used to transform or modularize those queries. While higher-order functions—functions that take other functions as input—offer a powerful solution for modularity in languages like Haskell or OCaml, they are notoriously difficult to implement efficiently for databases. The theoretical complexity of evaluating such queries is "non-elementary," suggesting that even simple abstractions could lead to intractable execution times. HOMES demonstrates that through specialized optimization techniques, these powerful abstractions can be made practical for real-world relational databases.

System Architecture and Methods

The HOMES system treats relational algebra operators (such as SELECT, JOIN, and FILTER) as constants within a simply-typed $\lambda$-calculus. This framework allows users to define "query templates" that accept other queries or views as parameters, promoting high levels of code reuse and succinctness.

To overcome the performance hurdles associated with higher-order evaluation, HOMES implements two primary strategies within its optimization engine:

  1. Graph Reduction: Rather than a "naive" evaluation that duplicates sub-queries (leading to exponential growth in SQL string size), HOMES utilizes a Directed Acyclic Graph (DAG). This ensures that shared sub-expressions are represented by a single node, eliminating redundant logic before SQL generation.
  2. Selective Materialization: The system identifies shared sub-graphs that represent intermediate data tables. It employs a cost-based model to decide whether to "materialize" these results into temporary tables, preventing the re-execution of expensive joins.
The HOMES system architecture, showing the optimization pipeline sitting atop a standard PostgreSQL engine.

The architecture, as shown above, operates as an intelligent compiler. It translates high-level functional terms into optimized SQL, which is then executed by a standard PostgreSQL engine.

Evaluation and Key Results

The effectiveness of HOMES was evaluated using the industry-standard TPC-H benchmark. Tests were conducted at two scales: Scale 1 (standard) and Scale 5 (larger volume) to assess performance under significant data pressure.

The performance gains achieved by the "Improved" (graph reduction and materialization) approach compared to a "Naive" implementation were dramatic. As shown in the results table, the optimizations transform theoretically "impossible" queries into near-instantaneous operations.

Performance comparison of the Improved vs. Naive evaluation strategies across various TPC-H queries and scales.

For instance, in Query 3 (involving 16 joins), the naive approach required 5.3 hours at Scale 1. In contrast, the HOMES optimized approach completed the same task in just 8.0 seconds. At Scale 5, where the naive approach timed out after 12 hours, HOMES finished in 10.1 seconds. These results prove that the theoretical complexity of higher-order languages does not preclude practical performance when appropriate sharing and materialization strategies are applied.

Key Insights and Future Work

HOMES demonstrates that the primary bottleneck in higher-order querying is often the redundancy generated during translation, rather than database execution itself. By borrowing "sharing" detection techniques from functional programming, HOMES eliminates this redundancy. Furthermore, it shows that complex query rewriting tasks can be unified within the language framework itself.

While HOMES represents a significant step forward, the authors note that "pathological" queries could still trigger worst-case non-elementary complexity. Future work involves refining the cost estimation models to better align with modern DBMS behavior and developing more sophisticated user interfaces to visualize the graph reduction process.

Summary updated

BibTeX
@article{vu2011homes,
  author = {Huy Vu and Michael Benedikt},
  title = {{HOMES: A Higher-Order Mapping Evaluation System}},
  journal = {Proc. VLDB Endow.},
  year = {2011},
}
Figure