-
Notifications
You must be signed in to change notification settings - Fork 40
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.