// the find
salsify/goldiloader
Just the right amount of Rails eager loading
Goldiloader monkey-patches ActiveRecord to automatically batch association loads — the first access to any association on one record triggers a bulk load for all records in the same query context. It's for Rails developers who are tired of sprinkling `includes` everywhere and want N+1 protection without thinking about it.
The automatic batching just works with no query annotations required — drop it in the Gemfile and your existing code gets faster. The custom `goldiload` block API extends the same batching mechanism to aggregations, Redis calls, or external APIs, which is genuinely useful beyond the AR association case. Thread-local enable/disable with block form means you can surgically opt out in background jobs or unusual code paths without blowing up the global default. Maintained across Rails versions with Appraisals covering 7.2 through edge, so it's not going to rot on a Rails upgrade.
The magic is also the hazard: you can load far more data than you intended if records from an unexpectedly large query context get grouped together, and the batching behavior is invisible in the code that triggers it. The `has_one` limit problem is a real footgun — associations like 'most recent post' silently load all posts for every record in context, which can tank production queries without any obvious cause. The lateral join workaround is correct but manual, shifting the cognitive burden back to the developer in exactly the cases that matter most. No async/fiber-aware batching support, so if you're running concurrent queries inside a single request this won't help you there.