Database Query Optimization via Runtime Predicate Evaluation

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing database query optimization methods rely on static analysis and table statistics, which can lead to poor execution plans due to outdated or incomplete data, especially when data characteristics change between compilation and query execution, resulting in inefficient query processing.

Innovation Solution

Implement dynamic query optimization techniques, such as dynamic predicate reordering, fast null processing, runtime constant optimization, and indirect branch optimization, which analyze and adjust query execution plans in real-time based on actual data characteristics and behavior during query execution.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of time

If static analysis at compile time is used to generate execution plans, then query optimization can be performed in advance, but the actual runtime behavior may be poor because data characteristics change between compilation and execution

Engineering Contradiction:
Improvequery execution timeVSAvoidexecution plan accuracy
Core Design Contradiction:
Loss of timeVSReliability

Solution Approach 1:

The system transitions from static compile-time query optimization to dynamic runtime optimization by continuously monitoring predicate evaluation performance and adapting the execution plan during query execution. The optimizer collects runtime statistics on predicate selectivity and reorders predicates dynamically based on observed data characteristics, ensuring the execution plan remains optimal despite changes in data state.

Inventive Principle:
Principle #15Dynamics

Solution Approach 2:

The system implements feedback mechanisms by monitoring predicate evaluation outcomes during query execution and using this information to adjust the execution plan. Runtime statistics on predicate performance are fed back to the optimizer, which then reorders predicates or modifies the execution plan to improve subsequent query performance based on observed data patterns.

Inventive Principle:
Principle #23Feedback

2Reliability

If table statistics are generated to improve execution plans, then query optimization can be more accurate, but generating statistics requires user intervention, uses intensive computations, and can be costly during heavy workloads

Engineering Contradiction:
Improveexecution plan accuracyVSAvoidsystem throughput
Core Design Contradiction:
ReliabilityVSProductivity

Solution Approach 1:

The system performs self-service by automatically collecting runtime statistics on predicate evaluation performance without requiring user intervention. The database engine monitors predicate selectivity and execution characteristics during normal query processing and uses this self-collected data to optimize execution plans, eliminating the need for manual statistics generation commands.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

Instead of collecting comprehensive table statistics that require intensive full-table scans, the system collects partial statistics focused specifically on predicate evaluation performance. By monitoring only the relevant aspects of data access patterns during query execution, the system achieves sufficient optimization accuracy without the overhead of complete statistics generation.

Inventive Principle:
Principle #16Partial or excessive action

3Adaptability or versatility

If statistics are collected automatically during heavy workloads, then execution plans can be updated in real-time, but this adds extra load to the system which can further degrade performance

Engineering Contradiction:
Improvequery optimization adaptabilityVSAvoidsystem computational load
Core Design Contradiction:
Adaptability or versatilityVSUse of energy by stationary object

Solution Approach 1:

The system performs continuous optimization by collecting predicate performance statistics during normal query execution without interrupting or pausing data processing. The optimization occurs as a continuous background activity that leverages existing query work to gather statistics, ensuring the system remains adaptive to changing data characteristics while maintaining uninterrupted productivity.

Inventive Principle:
Principle #20Continuity of useful action

Solution Approach 2:

The system uses an intermediary approach by collecting lightweight runtime statistics on predicate evaluation outcomes rather than performing heavy statistics generation. This intermediary measurement layer monitors query performance with minimal overhead and uses the collected data to trigger optimization only when beneficial, avoiding the computational burden of continuous full statistics regeneration.

Inventive Principle:
Principle #24Intermediary (Mediator)

4Productivity

If only a small percentage of table rows are sampled when gathering statistics, then statistics generation is faster, but the data collected may not be enough to determine selectivity patterns for complex queries

Engineering Contradiction:
Improvestatistics generation speedVSAvoidselectivity pattern accuracy
Core Design Contradiction:
ProductivityVSMeasurement precision

Solution Approach 1:

The system uses dynamic sampling that adapts to query complexity and data characteristics. For simple queries, minimal sampling maintains high speed. For complex queries with multiple predicates, the system dynamically increases sampling depth and collects more detailed runtime statistics on predicate interactions, achieving accurate selectivity patterns only when necessary while maintaining overall efficiency.

Inventive Principle:
Principle #15Dynamics

Data Source

PatentUS8204873B2System and method for query expression optimization
Publication Date: 2012.06.19 HEWLETT PACKARD ENTERPRISE DEV LP
  • US8204873B2 patent drawing
  • US8204873B2 patent drawing
  • US8204873B2 patent drawing

AI summary

A method provided for optimizing a query expression on a database engine of a database server. The query expression is sent to the database engine. The query expression contains a plurality of query language elements. The database engine initiates query processing of the query expression. An evaluation counter within the database engine increments an evaluation counter value corresponding to a query language element result. A flag is set within the database engine when the evaluation counter value reaches a threshold value. The database engine can then evaluate the efficiency of the query language elements in the query expression by comparing the evaluation counter value for each query language element against a set of optimization criteria.