A social media app experiences slow feed loading because each post requires a separate database call to fetch author details. Which pattern best resolves this N+1 query problem?
-
A
Add an index on the author_id column
-
B
Use eager loading with a JOIN to fetch posts and authors in one query
-
C
Cache each author record in localStorage
-
D
Switch from SQL to a document database