Runtime Statistics Mapping for Query Plan Cost Estimation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing query optimization systems in database management systems (DBMS) face inaccuracies in estimating data statistics for query plans, leading to sub-optimal plan selection due to errors in estimating internal node statistics, which are amplified through cascading effects, resulting in inefficient resource usage.

Innovation Solution

Implementing a system with runtime statistics feedback that collects and maps data statistics from executed query plans to a dictionary, allowing for more accurate estimation of internal node statistics and adaptive query plan optimization.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If cost-based query optimization uses estimated statistics for internal nodes, then query plan selection can be performed, but estimation errors are introduced leading to sub-optimal plans

Engineering Contradiction:
Improvequery plan selection efficiencyVSAvoidstatistics estimation accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The system performs preliminary actions by collecting and storing runtime statistics from executed query plans in a dictionary before they are needed for optimization. This pre-collection of actual statistics eliminates the need for error-prone estimation when optimizing subsequent queries, as the statistics are already available from real execution data.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system implements feedback by using runtime statistics collected from previously executed query plans to improve the accuracy of statistics estimation for subsequent query optimizations. The feedback loop continuously refines the statistics dictionary with actual execution data, enabling more accurate cost-based optimization over time.

Inventive Principle:
Principle #23Feedback

2Measurement precision

If runtime statistics collection is implemented, then statistics estimation accuracy improves, but system complexity increases

Engineering Contradiction:
Improvestatistics estimation accuracyVSAvoidsystem architecture complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The runtime statistics collection mechanism serves multiple functions: it collects actual statistics from query execution, stores them in a dictionary for future reference, and provides feedback for continuous refinement. This multi-functional approach consolidates what could be separate complex systems into a unified statistics management infrastructure.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Solution Approach 2:

The system serves itself by automatically collecting its own runtime statistics during normal query execution without requiring external intervention. The statistics are gathered as a byproduct of query plan execution, and the system uses these self-collected statistics to improve its own optimization accuracy.

Inventive Principle:
Principle #25Self-service

3Adaptability or versatility

If statistics are collected from executed query plans, then adaptability to dynamic data changes improves, but additional processing overhead is introduced

Engineering Contradiction:
Improveadaptability to data changesVSAvoidprocessing overhead
Core Design Contradiction:
Adaptability or versatilityVSUse of energy by moving object

Solution Approach 1:

The system maintains continuous collection of runtime statistics during normal query execution without interrupting or pausing operations. This continuous feedback mechanism ensures the statistics dictionary is constantly updated with current data characteristics, enabling real-time adaptability to changing data distributions while maintaining uninterrupted query processing.

Inventive Principle:
Principle #20Continuity of useful action

Data Source

PatentUS12353412B2Runtime statistics feedback for query plan cost estimation
Publication Date: 2025.07.08 SAP SE
  • US12353412B2 patent drawing
  • US12353412B2 patent drawing
  • US12353412B2 patent drawing

AI summary

A computer implemented method can execute a first query plan for a query, obtain statistics for internal nodes of a first query tree representing the first query plan, receive a second query tree representing a second query plan for the query, search for a matching internal node of the first query tree for a selected internal node of the second query tree, and responsive to finding the matching internal node of the first query tree, apply the statistics for the matching internal node of the first query tree to the selected internal node of the second query tree for estimating cost of the second query plan during query optimization of the query. Related systems and software for implementing the method are also disclosed.