> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ruby-active-record-query-in-loop

> A Ruby loop performs one Active Record lookup per item.

## What it flags

The standalone `loadwise perf polyglot` command detects a `find` or `find_by` call to a visible Active Record model inside an `each` block where the lookup uses its loop key.

## How to review or fix

Consider loading independent keys together if the query preserves the expected ordering, missing records and authorization scopes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.