Abstract
Traditional database systems process nested aggregate queries in a blocking fashion, forcing users to wait for complete results. This paper introduces a multi-threaded architecture for online aggregation that decouples inner and outer query blocks. By providing immediate, approximate feedback with statistical confidence intervals, the system reduces initial response times from minutes to seconds, allowing for a more interactive data exploration experience.
Introduction
In large-scale database systems, complex nested queries often create a "wait-and-see" bottleneck. A typical query might require the system to fully compute an aggregate in a subquery before any results from the outer query can be displayed. This paper, originally presented at VLDB 1999, addresses this issue by proposing a multi-threaded framework that provides continuous, improving feedback to the user.
Addressing the Blocking Nature of Nested Queries
Standard SQL execution is inherently blocking. For example, consider a query to find applicants with a salary above 60,000 whose GMAT score exceeds the average of all applicants in the USA. The system must first scan the entire dataset to calculate the average GMAT score (the inner query) before it can begin filtering the applicants (the outer query).
The researchers categorized these queries into types such as Type A (uncorrelated) and Type JA (join-aggregate/correlated). For massive datasets, the wait time for these aggregates can be prohibitive. While prior work enabled online aggregation for simple queries, nested queries remained a challenge because the outer query's validity depends on the evolving estimate of the inner aggregate.
Multi-Threaded Evaluation Model
To overcome the blocking limitation, the authors developed a multi-threaded evaluation model that treats the inner and outer query blocks as a producer-consumer pair:
- Thread IQ (Inner Query): This thread performs a randomized scan of the data to compute the aggregate. It continuously updates a running estimate and a confidence interval based on the Central Limit Theorem.
- Thread OQ (Outer Query): This thread consumes the current estimate from Thread IQ. It uses this "best guess" to filter tuples and return them to the user interface immediately.
- Incremental and Fuzzy Results: The system distinguishes between "certain" results (those that satisfy the condition even at the edges of the confidence interval) and "fuzzy" results (those that might be filtered out as the estimate refines).
The implementation includes a Java-based GUI where users can monitor the progress of both threads. A slider allows users to dynamically adjust the time-slice allocated to each thread, balancing the need for aggregate precision against the desire for a higher volume of results.
Experimental Results
The system was tested on a synthetic dataset of 1,000,000 applicant records. The results demonstrated a significant reduction in "initial response time":
- Traditional Model: Users waited over 700 seconds (nearly 12 minutes) for the first result.
- Multi-threaded Model: The first set of results appeared in just 10 to 20 seconds.
Even with only 10% of the data processed, the confidence intervals were often tight enough to provide highly accurate results. The study also noted that the time users spend reading results provides a natural window for the background threads to further refine the aggregates.
Insights and Limitations
A key insight of this work is the use of non-deterministic execution, where the user controls the trade-off between speed and accuracy. By identifying a "guaranteed" subset of results early, the system provides immediate value.
However, several challenges remain. The current model focuses on specific nesting patterns and may not easily scale to deeply nested or highly complex correlated subqueries. Additionally, the statistical guarantees rely on random data access; if data is sorted or skewed on disk, early samples might provide biased estimates. Finally, integrating such a multi-threaded architecture into existing commercial database engines would require significant changes to core components like the storage manager and buffer pools.
Summary updated