Query Caching in EJB Containers for Non-Primary Key Performance

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Current web application architectures are limited in caching query results, as only EJB instances using primary keys can be cached, while non-primary key queries often require database access each time, leading to performance issues.

Innovation Solution

Implementing a query caching system that allows caching of EJB instances at the query level, enabling storage of results from both primary and non-primary key queries in an in-memory cache, with mechanisms for query registration, cache management, and strategies for explicit and implicit caching, as well as dynamic query support.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Productivity

If only primary key queries are cached, then cache implementation is simple, but query performance for non-primary key queries deteriorates

Engineering Contradiction:
Improvequery performanceVSAvoidcaching system complexity
Core Design Contradiction:
ProductivityVSDevice complexity

Solution Approach 1:

The query caching system is designed to handle both primary key queries and non-primary key queries through a unified caching mechanism. The container's query component caches results for arbitrary queries regardless of query type, making the caching system universal and applicable to all query scenarios rather than being limited to only primary key queries.

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

Solution Approach 2:

The container acts as an intermediary between the EJB query component and the database. It introduces a query cache as a intermediate layer that stores query results, mediating between the query component and direct database access. This intermediary mechanism enables caching of non-primary key queries without requiring changes to the underlying database system.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Productivity

If non-primary key queries access the database each time, then data freshness is ensured, but application server performance deteriorates

Engineering Contradiction:
Improveapplication server performanceVSAvoiddatabase access time
Core Design Contradiction:
ProductivityVSLoss of time

Solution Approach 1:

The system performs preliminary actions by caching query results in the container before they are needed again. When a query is executed, its result is stored in the query cache in advance, so that subsequent identical queries can be served from the cache without accessing the database, thereby reducing database access time and improving application server performance.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

Instead of repeatedly accessing the database for identical queries, the system creates copies of query results and stores them in the container's cache. These cached copies serve as substitutes for actual database queries, reducing the frequency of database accesses and the associated time losses while maintaining data availability.

Inventive Principle:
Principle #26Copying

3Loss of energy

If query results are cached in the container, then database access is reduced, but cache management complexity increases

Engineering Contradiction:
Improvedatabase access operationsVSAvoidcache management complexity
Core Design Contradiction:
Loss of energyVSDevice complexity

Solution Approach 1:

The container's query component automatically manages the query cache without requiring external intervention. The system self-services by automatically caching query results, retrieving cached results when appropriate, and managing cache contents based on query component needs. This self-managing approach reduces the need for complex external cache management mechanisms.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The query caching functionality is merged with the container's existing query component rather than being implemented as a separate complex system. The cache management is combined with the query processing logic in the container, integrating caching operations with the existing EJB query mechanism and reducing overall system complexity.

Inventive Principle:
Principle #5Merging (Combining)

Data Source

PatentUS8019735B2Systems and methods for query caching
Publication Date: 2011.09.13 ORACLE INT CORP
  • US8019735B2 patent drawing
  • US8019735B2 patent drawing
  • US8019735B2 patent drawing

AI summary

A query caching system and method for enabling the caching of software object instances at the granularity of query level. A query component in a container can issue a query to retrieve a query result from a database within a scope of a transaction. The query result includes one or more instances of a class that represents one or more persisted data entries retrieved from the database. A cache management component retrieves the query result for the query in the cache when a query registration component finds out that another query matches the query in the query registry. If the class is expected to remain unchanged within the transaction, the class can be configured to be used concurrently by multiple users, using an optimistic concurrency strategy. The cached query result can be invalidated during the transaction, when any row in any table in the database associated with the cached query result, or a range of any data entry of the one or more persisted data entries in the query is updated or invalidated.