Abstract
Traditional database query optimizers often fail when faced with complex data correlations, particularly in XML and large-scale relational joins. This paper presents ROX-sampled, a run-time query optimizer specifically engineered for pipelined database systems. Unlike previous approaches that require full table materialization, ROX-sampled interleaves optimization with execution on small, representative data samples. This allows the system to proactively detect hidden correlations and select high-quality execution plans with minimal memory overhead.
Introduction
Database query optimization is traditionally a static process: the system analyzes a query, estimates intermediate result sizes using pre-calculated statistics, and commits to an execution plan before processing begins. However, this model frequently breaks down in modern environments like XQuery (XML) processing. Static statistics are often outdated or fail to capture complex dependencies between data attributes. For instance, an author appearing in one database conference is statistically likely to appear in others—a correlation that static models often miss, leading to catastrophic "plan failures" where query times explode.
The Challenge of Pipelined Systems
A previous iteration, ROX-full, addressed these issues by executing parts of the query on full datasets during the optimization phase to obtain accurate counts. While effective, this approach is incompatible with pipelined database engines. Pipelined systems stream data in small chunks to minimize memory usage; requiring full table materialization mid-query defeats this architectural advantage.
As shown in Figure 1, even a seemingly simple XQuery can translate into a complex join graph where the selectivity of each edge is difficult to predict without looking at the actual data.
Methodology: ROX-sampled
To bridge the gap between run-time optimization and pipelined execution, the authors proposed ROX-sampled. This framework replaces full-table execution with a multi-tiered sampling strategy.
Multi-Tiered Data Management
The system maintains three levels of data for every query step:
- Full Table (FT): The base data stored on disk.
- Full-Sample (FS): A representative sample (e.g., 1,000 rows) updated dynamically.
- Sample (S): A tiny subset used for "chain sampling" to rapidly test potential execution paths.
Proactive Optimization
ROX-sampled is "proactive" rather than "reactive." Instead of waiting for a plan to fail, it uses "chain sampling" to explore sequences of operators on small samples. This allows the optimizer to detect whether a join sequence is highly selective or "explosive" before committing resources.
Figure 3 illustrates the architectural shift. While ROX-full cycles between optimization and execution using full data, ROX-sampled performs its optimization loop on sample data, only moving to full execution once a plan is finalized.
Evaluation and Results
The system was evaluated using a 100x replicated version of the DBLP XML dataset, resulting in a 45GB testbed. The researchers specifically targeted "correlation traps" by clustering documents into research areas to simulate real-world data dependencies.
- Plan Quality: ROX-sampled achieved high fidelity, selecting the same optimal join order as ROX-full in 73% of cases using a sample size of only 1,000.
- Performance and Robustness: While sampling introduces a minor overhead (6-9% slower than the idealized ROX-full), it remains vastly superior to static optimizers. In scenarios where traditional optimizers suffered 10x-100x slowdowns due to unexpected correlations, ROX-sampled remained stable and efficient.
Conclusion and Future Work
ROX-sampled demonstrates that run-time optimization is feasible for memory-constrained, pipelined systems. By using statistically significant samples as a proxy for reality, the system avoids the pitfalls of static estimation. Future work will focus on reducing redundant sampling work and expanding the framework to support a broader range of operators, such as sorting and grouping.
Summary updated