There are two main questions to consider when loading data from a database or other external system:
- Should I load the data at the start, or when I need it?
- Once I have the data, should I save it for reuse?
The answers to these questions give you the four patterns of data loading:
- Lazy Load – Load as needed, don’t reuse
- Pre-Fetch – Load at the beginning, don’t reuse
- Read Through Cache – Load as needed, save the results for reuse
- Pre-Cache – Load all the data at the beginning
Each pattern has pros and cons:

Picking the right, or wrong, pattern for you use case can have major performance and scaling implications.
These are the main questions to ask yourself:
- How often does the data change?
- How important is the performance of the code’s critical path?
- How likely am I to reuse the data?
- How much do I know about the data I need?
3 comments On Four Patterns Of Data Loading
Pingback: Tradeoffs with the Four Patterns Of Data Loading – Sherman On Software ()
Pingback: How Running Off A Messaging Queue Impacts Data Loading Strategies – Sherman On Software ()
Pingback: Patterns of Data Loading – Topics and Broadcast – Sherman On Software ()