Query Mesh: An Efficient Multi-Route Approach to Query Optimization

Rimma V. Nehme, Karen Works, Elke A. Rundensteiner, Elisa BertinoPurdue 2008

Abstract

In most database systems, traditional and stream systems alike, the optimizer picks a single query plan for all data based on the overall statistics of the data. It has however been repeatedly observed that real-life datasets are non-uniform. Selecting a single execution plan may result in a query execution that is ineffective for possibly large portions of the actual data. In this paper, we present a practical alternative to the current state-of-the-art query optimization techniques, termed a multiroute query mesh model (or short QM). The main idea of QM is to compute multiple routes (query plans), each designed for a particular subset of data with distinct statistical properties. Based on the execution routes and the data characteristics, a classifier model is induced. The classifier is used for efficient partitioning of the new data to assign the best route for query processing. We formulate the QM search space and analyze its complexity. To find optimal query meshes, we design the Opt-QM algorithm. Faced with a dilemma – whether to determine distinct data subsets or to compute a set of execution routes first, we design several heuristics that can effectively find good quality query meshes very efficiently. For runtime query processing, we employ a Self-Routing Fabric (SRF) infrastructure which supports shared operator processing and has near-zero routing overhead. Results of our experimental study with real-life and synthetic data indicate that QM-based approach consistently provides better query execution performance for skewed datasets compared to the state-of-the-art alternatives, namely both the traditional systems that employ a single pre-computed plan execution and also the systems that determine different routes on-the-fly.

Introduction

Most database query optimizers are monolithic, calculating a single "best" execution plan based on the average statistics of an entire dataset. However, real-world data streams—such as stock market feeds or network traffic—are rarely uniform. A plan optimized for average behavior often fails to perform efficiently for large, skewed subsets of the data.

Query Mesh positioning in the optimization landscape, bridging the gap between route-oriented and route-less systems.

Previous attempts to solve this have fallen into two extremes. Traditional route-oriented systems pre-compute a single plan; they are fast to execute but lack the granularity to handle data skew. Conversely, route-less systems (e.g., Eddies) route every tuple individually at runtime. While highly adaptive, these systems suffer from massive per-tuple processing overhead. Query Mesh (QM) introduces a middle-ground approach that provides the flexibility of multiple plans without the crippling overhead of per-tuple re-optimization.

The Query Mesh Framework

The Query Mesh framework consists of two primary components: a specialized optimizer and a novel execution engine.

QM Optimizer

Instead of finding one plan, the QM optimizer searches for a "mesh"—a combination of a classifier and a set of execution routes. Because finding the absolute optimal mesh is NP-hard (the search space size is defined by the Bell number), the authors developed several cost-based heuristics, including Iterative Improvement (II-QM) and Simulated Annealing (SA-QM), to find high-quality solutions efficiently.

High-level architecture of the Query Mesh, showing the classifier and multiple execution routes.

Self-Routing Fabric (SRF)

The SRF is the runtime execution engine designed to avoid the bottlenecks of centralized routing. It utilizes r-tokens (metadata carrying the route) and rusters (routable clusters of tuples). Incoming tuples are batched into rusters based on the classifier's decision, allowing them to flow through operators in a distributed, decentralized fashion. By routing groups rather than individuals, QM significantly reduces the metadata and CPU overhead associated with previous multi-route systems.

Key Results and Insights

The researchers evaluated QM using real-world financial data, sensor readings, and synthetic streams. The results demonstrate that QM provides a robust alternative to existing optimization techniques:

  • Throughput: QM achieved 60-100% higher output rates than traditional single-plan systems and 10-40% higher than existing adaptive systems on skewed datasets.
  • Efficiency: The runtime overhead of the classifier was remarkably low, accounting for only 2-4% of the total execution cost.
  • Memory Footprint: QM's memory usage was 10-38% lower than other multi-route alternatives because it avoids the heavy lineage-tracking bitmasks required by tuple-level routing systems.

One of the core innovations is the use of a Decision Tree classifier to bridge the gap between data characteristics and execution plans. This allows the system to "compile" complex data-to-plan mapping into a very fast runtime lookup, typically requiring only 2-3 simple checks per ruster.

Conclusion

Query Mesh offers a practical and efficient solution for query optimization in the presence of non-uniform data. By combining machine-learning-based classification with a decentralized execution fabric, it achieves high throughput with minimal overhead. Future work will focus on making QM fully adaptive, enabling the mesh to reconfigure itself on-the-fly as data distributions shift over time.

Summary updated

BibTeX
@inproceedings{nehme2008query,
  author = {Rimma V. Nehme and Karen Works and Elke A. Rundensteiner and Elisa Bertino},
  title = {{Query Mesh: An Efficient Multi-Route Approach to Query Optimization}},
  booktitle = {Purdue},
  year = {2008},
}
Figure