Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Compatibility alias for the Elixir/Phoenix plugin's N+1 query checker. Invoke explicitly with /ecto:n1-check.
.claude/skills/oliver-kriska-n1-check/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-07 | ✗→✓ | ▲ Improved | -10% | 0% |
| case-13 | ✗→✓ | ▲ Improved | 11% | 0% |
| case-02 | ✓→✓ | = Same ✓ | -25% | 0% |
| case-03 | ✓→✓ | = Same ✓ | -4% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 50% | 0% |
Identify and fix N+1 query anti-patterns in Ecto/Phoenix applications.
Enum.mapjoin + preload when filtering by associationelixir# BAD: N+1 queries users |> Enum.map(fn user -> Repo.get(Order, user.order_id) end) # GOOD: Single query with preload users |> Repo.preload(:orders)
elixir# BAD: Lazy loading triggers N queries for user <- users do user.posts # Triggers query for each user! end # GOOD: Eager load first users = Repo.all(User) |> Repo.preload(:posts) for user <- users do user.posts # Already loaded end
elixir# BAD: N+1 for nested associations user.posts |> Enum.map(fn post -> post.comments end) # GOOD: Nested preload Repo.preload(user, posts: :comments)
Use Grep with context lines (-B 5 -A 5) to find Enum.map near Repo. calls in lib/**/*.ex. Use Grep to find association access patterns (.posts, .comments, .orders) in lib/**/*.ex. Use Grep with context (-B 3) to find Repo.get or Repo.one near loop patterns (for, Enum) in lib/**/*.ex.
For a context module, run:
Use Grep to find all Repo. calls in the context module, then verify each has appropriate preloads.
Then verify each query has appropriate preloads.
For detailed patterns, see:
${CLAUDE_SKILL_DIR}/references/preload-patterns.md - Efficient preloading strategies${CLAUDE_SKILL_DIR}/references/query-optimization.md - Query batching techniquesOther measured skills in the registry, with their headline benchmark lift.