Blog
Thoughts on software engineering, web development, and technology
Two Practical Lessons I Picked Up Building an LTI Integration
A small LTI integration turned into two useful lessons: when to use Stimulus over Turbo, and why exists? is better than find_by for boolean checks
That Time I Fixed a Sneaky N+1 Query in Grade Calculations
How I reduced 40+ database queries to just 5 by fixing N+1 issues in grade calculations
ActiveRecord has_many Joins, DISTINCT, and When ORDER BY Needs a Subquery
Joining has_many multiplies parent rows; DISTINCT dedupes them. In PostgreSQL, DISTINCT plus ORDER BY on joined columns can error—wrap the deduped set in a subquery, then join and order on the outside.
ActiveRecord DISTINCT ORDER BY Error in PostgreSQL and Why a Subquery Fixes It
Seeing `for SELECT DISTINCT, ORDER BY expressions must appear in select list` in PostgreSQL? In ActiveRecord, a `has_many` join can require `DISTINCT`, but ordering by joined columns may need a subquery with `from(subquery, :alias)`.
Concurrent Indexes, Statement Timeouts, and When Migrations Stop Being “Deterministic”
Adding a column and a concurrent index on a huge table: the column landed, the index timed out under migration limits. disable_ddl_transaction!, statement_timeout reset, and idempotent add_column/add_index let a redeploy finish what the first run started.
Built by Sam Lee with
♥