Monday, 14th April 2025
📝 Query optimization in rails #
It’s been awhile since I’ve gone deep on optimizing queries in rails. Over the years I’ve settled into two default approaches: (1) drop into raw SQL and write CTEs that help get a clean set of the final activerecord objects I’m looking for, or (2) add various cache columns to tables such as last_comment_id to greatly simplify the SQL.
I came across this discussion online that did a great job of surveying a whole range of approaches including some new ones I have never tried. This article offered a great summary of the options and I learned Rails now supports CTEs natively.
💡 TIL: React in Rails is gaining momentum with Inertia #
I am seeing more activity around an elegant way to utilize React in Rails. I plan to try this out soon and these articles are a good starting point. There is even a shadcn starter project which is part of my motivation.