Solving N+1’s with Rails `exists?` queries
Jan 10, 2023Mike Coutermarsh

Summary
This post addresses a performance issue in a Rails application caused by multiple N+1 `.exists?` queries on a single API endpoint. It explains why `includes` does not work with `exists?` queries and presents a solution by preloading records and checking them in memory. It also introduces an alternative approach using a new association to preload only necessary records.