JSON Schema Redesign for Query Cost Optimization
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for fetching data from nested JSON structures in NoSQL databases require complex code and result in increased response time and memory consumption, negatively impacting application performance.
Innovation Solution
A method that calculates the cost of data fetching based on query execution time and nested layers, and re-designs the JSON document schema using historical query patterns and execution times to optimize data retrieval, reducing complexity and improving performance.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Loss of time
If data is fetched by traversing nested JSON structures, then data can be retrieved from NoSQL databases, but query execution time increases and application performance deteriorates
Solution Approach 1:
The system performs preliminary analysis of query patterns and JSON schema structures to identify optimization opportunities before actual data fetching occurs. By pre-calculating traversal costs and identifying high-cost query patterns, the system can proactively optimize schema designs and query approaches, thereby reducing execution time and improving application performance.
2Adaptability or versatility
If complex nested JSON schemas are used to represent complex data, then data representation capability improves, but traversal complexity and memory consumption increase
Solution Approach 1:
The system dynamically changes parameters related to JSON schema traversal by analyzing query patterns and identifying high-cost access paths. It transforms the traversal approach by selecting alternative fields or restructuring queries based on calculated costs, thereby reducing traversal complexity while maintaining the ability to represent complex data structures.
3Reliability
If thorough traversal of nested JSON layers is performed to fetch required data, then data retrieval completeness improves, but memory consumption and processing overhead increase
Solution Approach 1:
The system extracts and analyzes specific high-cost traversal paths from the JSON structure by calculating access costs for different fields. It identifies and removes unnecessary traversal steps by selecting optimal access paths based on query patterns and schema structure, thereby reducing memory consumption and processing overhead while ensuring complete retrieval of required data.
Data Source
AI summary
An approach is provided for optimizing data fetching. A query employing a method to fetch data from a JSON document is received. An amount of time required to execute the query and a number of nested layers in a traversal of the JSON document required to fetch the data are determined. Based on the amount of time and the number of nested layers, a cost associated with an execution of the query is calculated. The cost is determined to exceed a threshold value. Responsive to the determination that the cost exceeds the threshold value and using historical query patterns and historical query execution times, a schema of the JSON document is re-designed. The data is fetched from the JSON document using the re-designed schema.


