Four Patterns Of Data Loading

There are two main questions to consider when loading data from a database or other external system:

  1. Should I load the data at the start, or when I need it?
  2. Once I have the data, should I save it for reuse?

The answers to these questions give you the four patterns of data loading:

  1. Lazy Load – Load as needed, don’t reuse
  2. Pre-Fetch – Load at the beginning, don’t reuse
  3. Read Through Cache – Load as needed, save the results for reuse
  4. 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

Leave a Reply

Site Footer

Discover more from Sherman On Software

Subscribe now to keep reading and get access to the full archive.

Continue reading