Skip to content
Latchkey

What Is Lazy Loading in Data Access?

Lazy loading in data access is a strategy where related records are not retrieved until code first reads them. Accessing an unloaded association triggers a query on the spot. It saves work when associations go unused but can hide expensive queries behind ordinary property access.

Why it matters

Lazy loading keeps initial queries lean, yet careless use inside loops is a classic source of the N+1 query problem. Knowing when data loads helps you avoid surprise round trips.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →