Provenance-based Data Skipping (TechReport)

Xing Niu, Ziyu Liu, Pengyuan Li, Boris GlavicarXiv 2021

Introduction

Database query optimization traditionally relies on static analysis—examining query text before execution to determine which data to access. While effective for simple filters (e.g., WHERE state = 'CA'), this approach fails for data-dependent queries, such as top-k results or complex aggregations. In these cases, the relevance of a specific row depends on the values of other rows in the dataset, forcing databases to perform expensive full table scans.

Provenance-based Data Skipping (PBDS) is a novel optimization technique designed to address this inefficiency. By leveraging runtime query provenance, PBDS identifies and skips irrelevant data for future queries, providing significant speedups for analytical workloads.

The Challenge of Data-Dependent Queries

Static analysis cannot generate declarative filters for queries where the "interest" of a row is determined by the global state of the data. For example, finding the "top 5 states by average income" requires processing a large portion of the table before any data can be safely discarded.

Example queries Q1 (static filter) and Q2 (data-dependent aggregation) illustrating the limitations of traditional skipping.

As shown in the figure above, while $Q_1$ can be optimized by a simple index on the state column, $Q_2$ involves a GROUP BY and ORDER BY with a LIMIT, making it impossible to know which states will be in the top result without initial processing. PBDS bridges this gap by capturing which data actually contributed to the result of such queries and summarizing that information into compact bitvector sketches.

Methodology: Provenance Sketches

PBDS operates through a capture-and-reuse cycle consisting of three primary steps:

  1. Capture via Instrumentation: The system rewrites incoming queries to track their "provenance"—the specific input tuples that contributed to the final output. To keep overhead low, PBDS maps rows to horizontal fragments (e.g., ranges of a primary key) and records which fragments contained contributing data in a bitvector sketch.
  2. Sketch Safety & Reusability: Not all captured sketches are safe to reuse. For instance, skipping a fragment during an aggregation might lead to incorrect results. The authors developed a formal logic called Generalized Containment to prove whether a sketch can be safely applied to a specific query or its variants.
  3. Data Skipping: Once a sketch is verified as safe, subsequent queries are instrumented with a generated WHERE clause. This clause restricts the scan to only the fragments identified in the sketch, allowing the database to leverage existing physical design artifacts like zone maps or BRIN indexes.

Formal Verification of Sketch Safety

To ensure correctness, PBDS uses an SMT solver (Z3) to statically prove sketch safety. This involves checking if a sketch preserves the integrity of monotone aggregations (like COUNT, MAX, or SUM over positive numbers).

Formal rules for Generalized Containment (gc) and provenance propagation (Psi) used to prove sketch safety.

The formal logic shown above allows the system to determine if a sketch $X$ is sufficient to compute query $Q$ correctly. This rigorous approach enables data skipping even for complex analytical queries that were previously considered "un-skippable."

Experimental Results and Impact

The authors evaluated PBDS across standard benchmarks (TPC-H) and real-world datasets (Chicago Crimes, MovieLens, Stack Overflow). The results demonstrate substantial performance gains:

  • Query Speedup: PBDS achieved up to a 40x speedup on TPC-H Q3 by drastically reducing the volume of data scanned.
  • Real-world Performance: For the Chicago Crimes dataset (~6.7M tuples), query performance improved by 88.5%.
  • Low Overhead: The instrumentation cost for capturing a sketch is typically less than 20% of the initial query runtime, an investment that is quickly amortized over subsequent executions.
  • System Agnostic: The technique proved effective in both Postgres (disk-based) and MonetDB (columnar memory-based), highlighting that reducing data volume is a universal benefit.

Conclusion and Future Work

PBDS reimagines provenance as a lightweight, self-tuning index that captures the workload's "interest." While highly effective for OLAP workloads, the current implementation focuses on read-only data. Future research is needed to maintain sketches under frequent updates and to optimize the heuristic thresholds for capturing versus reusing sketches. Despite these limitations, PBDS represents a significant step forward in making data-dependent analytical queries as efficient as their statically-filtered counterparts.

Summary updated

BibTeX
@misc{niu2021provenance,
  author = {Xing Niu and Ziyu Liu and Pengyuan Li and Boris Glavic},
  title = {{Provenance-based Data Skipping (TechReport)}},
  year = {2021},
  eprint = {2104.12815},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2104.12815},
}
Figure