MetaCredo.Check.Warning.NPlusOneQuery (MetaCredo v0.1.0)

View Source

Detects database operations (e.g. Repo.get, Repo.one) called inside collection operations like Enum.map/2 or Enum.each/2. This creates an N+1 query problem where N extra queries are issued for N items.

Use Repo.preload/2, from(..., preload: [...]), or batch the query outside the loop.

Category: Warning / Priority: high