Abstract
Data provenance is essential for auditing and debugging database operations, yet the instrumented SQL queries required to track it often suffer from extreme performance degradation. This paper presents a cost-based optimization (CBO) framework and provenance-specific algebraic transformations (PATs) implemented in the GProM middleware. By optimizing queries before they reach the database engine, the system achieves performance improvements of over four orders of magnitude, making on-demand provenance tracking feasible for complex workloads.
Introduction
Data provenance tracks the origin of data and the specific operations that produced it, serving as a highly detailed audit trail for database systems. A standard method for capturing this information is "instrumentation," a technique that rewrites original SQL queries so they carry along provenance annotations. These annotations track exactly which input rows combined to create a specific output row, as shown in the example below.
While effective for tracking, these rewritten queries are often massive, complex, and structurally unusual. Standard Relational Database Management System (DBMS) optimizers are not designed to handle such queries, frequently failing to simplify redundant operations or optimize join orders. This leads to execution times that are often several orders of magnitude slower than the original query.
The Optimization Challenge
The primary bottleneck in provenance computation is the "black box" nature of the DBMS optimizer. Because the optimizer does not understand the semantic intent behind the instrumented query, it often produces suboptimal execution plans. Common issues include:
- Redundant Operations: Failure to eliminate duplicate-elimination operators that are unnecessary in the context of provenance.
- Join Reordering Blocks: Complex instrumentation structures can prevent the optimizer from reordering joins effectively.
- Expression Blow-up: Exponential growth in the size of expressions during the rewriting process.
The GProM Optimization Framework
To address these challenges, the authors developed an optimization layer that sits on top of the standard DBMS, implemented within the open-source GProM middleware. The framework employs three core strategies:
1. Provenance-specific Algebraic Transformations (PATs)
The system applies a set of heuristic equivalence rules specifically designed for provenance. These include delaying the duplication of attributes until necessary and factoring out common attributes to prevent query size blow-ups. These transformations "clean up" the query into a shape that the underlying DBMS can optimize more effectively.
2. Instrumentation Choices (ICs)
There is often more than one way to rewrite a query for provenance. For example, propagating provenance through an aggregation can be achieved via a JOIN or a WINDOW function. The framework identifies these "choice points" where multiple valid instrumentation strategies exist.
3. Cost-Based Optimization (CBO)
Rather than relying solely on heuristics, GProM uses a CBO framework to select the best instrumentation strategy. It generates multiple alternative SQL plans and queries the backend DBMS for cost estimates. This is managed through a MAKECHOICE callback API, allowing the optimizer to explore the search space using strategies like Simulated Annealing without requiring modifications to the database engine itself.
Experimental Evaluation
The framework was evaluated using the TPC-H benchmark (10MB to 10GB), a synthetic dataset for transaction provenance, and the DBLP co-author dataset.
Key Results
- Massive Speedups: The combination of CBO and PATs improved query performance by over four orders of magnitude compared to unoptimized queries.
- Criticality of PATs: Deactivating provenance-specific transformations resulted in an average runtime increase of approximately 1,800x, reaching up to 12,000x in extreme cases.
- CBO Accuracy and Overhead: The cost-based optimizer successfully identified the best instrumentation method in nearly all cases, with an average performance penalty of only 4% when it failed. The optimization overhead was minimal, typically around 50ms.
Conclusion
The GProM framework demonstrates that provenance tracking can be made efficient by applying domain-specific optimizations before the query reaches the database engine. By combining heuristic transformations with a cost-based selection of instrumentation strategies, the system bridges the gap between the complex requirements of provenance and the capabilities of standard database optimizers. Future work will focus on refining cost estimation and exploring compressed provenance representations to further enhance scalability.
Summary updated