Selectivity Estimation on Set Containment Search

Yang Yang, Wenjie Zhang, Ying Zhang, Xuemin Lin, Liping Wang

Introduction

Selectivity estimation—the task of predicting the number of records that satisfy a given query—is a cornerstone of database query optimization. While techniques for standard relational queries are well-established, set containment search presents unique challenges. Given a query set $Q$, a containment search identifies all records $X$ in a dataset $S$ such that $X \subseteq Q$. This operation is vital in diverse fields, from recruitment platforms matching candidate skills to job requirements, to e-commerce systems filtering products by sets of attributes.

The complexity of set containment estimation arises from three primary factors: high dimensionality (vocabularies often exceeding millions of elements), massive dataset scales, and significant data skew. Traditional sketching techniques, such as K-Minimum Values (KMV), are optimized for set intersections but struggle with the subset logic inherent in containment queries, often leading to high estimation errors in high-dimensional spaces.

Methodology: Trie-Based Sampling

To overcome the limitations of traditional sketching, this research introduces a hierarchy of sampling-based approaches that leverage the structural properties of the data. The central innovation is the use of an ordered trie to partition the dataset based on frequent element patterns.

Example dataset records and query set used to illustrate partitioning.

As illustrated in the table above, records $X_1$ through $X_8$ are composed of various elements $e_i$. By ordering these elements by frequency and building a trie, the dataset can be organized into distinct partitions.

Ordered trie structure for dataset partitioning and pruning.

OT-Sampling and DC-Sampling

The authors propose two primary algorithms based on this structure:

  1. OT-Sampling (Ordered Trie-based): This method performs stratified sampling across the trie's partitions. By grouping records that share common high-frequency prefixes, OT-Sampling ensures that the sample set accurately reflects the underlying distribution of the data, significantly outperforming simple random sampling.
  2. DC-Sampling (Divide-and-Conquer): This algorithm introduces a powerful pruning mechanism. Because a record $X$ can only be a subset of $Q$ if all its elements are in $Q$, any partition whose prefix contains an element $e \notin Q$ can be immediately discarded. This "divide-and-conquer" approach allows the system to skip irrelevant data entirely, focusing its sampling budget on the most promising records.

Experimental Evaluation

The effectiveness of these methods was evaluated across nine diverse, real-world datasets, including Bookcrossing, Netflix, and Amazon. These datasets varied in average record length and vocabulary size, with some containing over 7 million distinct elements.

Key Results

  • Accuracy Improvements: DC-Sampling consistently outperformed existing methods. It reduced the relative error of simple random sampling by approximately 60% and achieved an 80% reduction in error compared to the IL-GKMV sketch-based baseline.
  • Computational Efficiency: The pruning techniques in DC-Sampling allowed for faster estimation by narrowing the search space dynamically. This makes the approach highly scalable for large-scale production environments.
  • Robustness: The trie-based methods demonstrated stable performance across varying memory budgets, showing a smooth improvement in accuracy as the sample size increased.

Conclusion

This research demonstrates that data-aware sampling, guided by ordered trie structures, provides a superior alternative to traditional sketching for set containment selectivity estimation. By leveraging the logical constraints of containment queries through divide-and-conquer pruning, the proposed DC-Sampling algorithm achieves significant gains in both accuracy and efficiency. These findings offer a robust framework for optimizing complex set-based queries in modern high-dimensional databases.

Summary updated

BibTeX
@inproceedings{yang2019selectivity,
  author = {Yang Yang and Wenjie Zhang and Ying Zhang and Xuemin Lin and Liping Wang},
  title = {{Selectivity Estimation on Set Containment Search}},
  booktitle = {DASFAA},
  year = {2019},
  doi = {10.1007/978-3-030-18576-3\_20},
}
Figure