by resonious · 2y ago · 0 comments
Also, a proficient developer looks at the SQL logs anyway as they develop a given feature.
Rails' flavor of ORM is particularly composable and transparent - you can easily mix/match it with vanilla SQL.
This is a place where I think tools like Rubocop help. They can be configured to point out method swaps like this (size over count) automatically which is a relatively low effort task to change the code.
With those rules/linting in place, you aren’t throwing out the benefits of AR (ORM), and hopefully leveraging their useful methods like these that help avoid unnecessary queries.
More concretely, performance is on my list of "good problems to have". Businesses die in the time it takes to write raw SQL.