Green-Software-Foundation / Green-Software-Foundation/patterns

Reduce Database Queries and Network Calls

Open
#378 2 comments 0 reactions 2 assignees Claimed by @franziska-warncke View on GitHub
proposed pattern
Dominant language
TypeScript
Stars
145
Forks
44
Avg merge
13d 22h
Merged PRs (30d)
1

Description

**Describe the pattern you'd like to propose**
As a software developer or architect, I want to reduce the number of database requests, so that the application performs its operations more efficiently in terms of latency, overall run time, and energy consumption.

Especially ORM tools like Hibernate in Java can execute additional, unwanted queries if relationships between entities are wrongly configured.

**Describe specific emission impact from this pattern**
Reducing the number of database requests reduces the amount of blocking I/O operations, which improves the overall performance of the application and thereby reduces its energy consumption.

SCI score: SCI = (E * I) + M per R
The energy consumed (E) is reduced by reducing the amount of requests that travel the network, and by reducing the execution time of services, so they can be scaled down earlier.

**References to this pattern**
I haven't seen this as a pattern, but I eager/lazy loading issues in Hibernate/JPA are a well known problem (e.g. N+1 problem).

**Additional context**
A selected use case performs an operation on a large dataset resulting in too many database requests, such as N+1 requests, where N is the amount of items in the dataset, and +1 refers to an additional request to fetch an eagerly loaded relation for each item.
The issue of too many database requests may also arise from lazy loaded relations that are accessed after the initial fetch of the dataset.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.