Performance-Based Query Plan Caching for Database Resource Optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Query planning in database systems is resource-intensive, consuming time and resources that could be allocated to other queries or tasks, highlighting the need for techniques that reduce this burden without compromising performance.

Innovation Solution

Implementing performance-based caching of query plans, where frequently executed queries are stored in a cache, and their execution is optimized using performance metrics to anticipate workload changes and predict likely queries, thereby reducing the need for constant regeneration of query plans.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If query planning is performed for every query to ensure optimal execution, then query execution efficiency is improved, but resource consumption and time overhead increase

Engineering Contradiction:
Improvequery execution efficiencyVSAvoidresource consumption
Core Design Contradiction:
ProductivityVSLoss of energy

Solution Approach 1:

The system performs query planning in advance by maintaining a cache of pre-generated query plans. When a query is received, the system checks the cache for an existing plan that can be reused, eliminating the need to perform full query planning for every query. This preliminary action of caching plans resolves the contradiction by preparing execution plans beforehand, thus improving execution efficiency while reducing per-query resource consumption.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system creates and stores copies of query plans in a cache memory structure. Instead of generating a new query plan for every query, the system retrieves copied plans from the cache that match the incoming query. This copying mechanism allows the system to reuse proven execution plans, thereby improving productivity while minimizing the energy and resources required for repeated planning operations.

Inventive Principle:
Principle #26Copying

2Loss of energy

If query plans are cached to reduce planning overhead, then resource consumption decreases, but cache memory usage increases

Engineering Contradiction:
Improveresource consumptionVSAvoidcache memory usage
Core Design Contradiction:
Loss of energyVSQuantity of substance

Solution Approach 1:

The system implements partial caching by storing only the most frequently executed query plans in the cache, rather than caching all possible query plans. The cache operates with a limited capacity and uses eviction policies to maintain only the most valuable plans. This partial action approach reduces memory usage while still achieving significant resource savings by caching enough plans to handle the majority of queries efficiently.

Inventive Principle:
Principle #16Partial or excessive action

Solution Approach 2:

The system dynamically adjusts cache management parameters such as cache size limits, eviction thresholds, and plan selection criteria based on workload characteristics. By changing these parameters, the system optimizes the balance between cache memory usage and resource consumption, ensuring that the cache occupies minimal memory while still providing sufficient plan reuse to reduce overall resource demands.

Inventive Principle:
Principle #35Parameter changes

3Adaptability or versatility

If comprehensive query planning is performed to handle diverse query types, then adaptability improves, but complexity of the planning process increases

Engineering Contradiction:
Improvequery handling capabilityVSAvoidplanning process complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The system segments the query planning process into distinct phases: query parsing, cache lookup for plan retrieval, plan validation, and fallback to full planning if needed. This segmentation allows the system to handle diverse query types efficiently by first attempting simple cache retrieval and only engaging in complex planning when necessary. The segmented approach maintains adaptability while reducing the perceived and actual complexity of the overall planning process.

Inventive Principle:
Principle #1Segmentation

Solution Approach 2:

The query plan cache serves multiple functions: it stores execution plans, provides quick retrieval paths, validates query patterns, and guides fallback planning when plans are not found. This multi-functionality allows the system to maintain high adaptability across diverse query types while using a single unified caching mechanism, thereby reducing the complexity that would arise from implementing separate handling mechanisms for different query categories.

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

Data Source

PatentUS11093496B1Performance-based query plan caching
Publication Date: 2021.08.17 AMAZON TECH INC
  • US11093496B1 patent drawing
  • US11093496B1 patent drawing
  • US11093496B1 patent drawing

AI summary

Performance-based caching may be implemented for query plan caches that are used to provide query plans to perform queries instead of generating query plans to perform queries. Performance metrics for queries performed at a database may be collected and used to cache query plans generated for the queries. When a query is received that matches one of the queries, the cached plan corresponding to the matching query may be used to perform the query.