Tech
Stop Guessing Between .count, .length, and .size in Rails
When investigating a slow Rails endpoint, it's common to start by looking for N+1 queries, missing indexes, or expensive joins. Sometimes, though, the real culprit is much smaller.
It might be hiding in a method call you've written hundreds of times without thinking about it.
In Rails, .count , .length , and .size all return a number, and many developers use them interchangeably. Under the hood, however, they behave very differently.
Let's break down how each method works and see wh...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to