Rails Daily

Rails Daily: Weekly Recap - Database Performance & Optimistic Locking

Rails merged 20 pull requests this week, featuring significant PostgreSQL improvements with RETURNING clause support for virtual columns and comprehensive RETURNING statement implementation across INSERT, UPDATE, and DELETE operations. Critical fixes addressed optimistic locking rollback behavior and strict loading violations.

Duration: PT2M13S

https://podlog.io/listen/rails-daily-a67c65cf/episode/rails-daily-weekly-recap-database-performance-optimistic-locking-a0a5421a

Transcript

Good morning. This is Rails Daily for the week of May 10th through 17th, 2026.

Twenty pull requests merged with thirty additional commits this week.

Starting with database features: PostgreSQL users gained automatic virtual column reloading on updates through the RETURNING clause, eliminating extra database round trips. This builds on broader RETURNING statement support now available for INSERT, UPDATE, and DELETE operations in Arel, enabling queries that modify and return data in a single operation.

Performance improvements include optimized insert_all operations for tables with serialized columns, skipping unnecessary coder round-trips for Hash and Array values. The team also enhanced expression index syntax, allowing array notation like ["lower(email)", :status] alongside traditional string syntax.

Critical fixes this week addressed optimistic locking behavior. Lock version counters now properly reset after transaction rollbacks, preventing StaleObjectError exceptions on subsequent saves. Strict loading violations were fixed for pluck operations, ensuring consistent enforcement across query methods.

Active Storage received the long-requested attach! method, providing a "bang" variant that raises exceptions on validation failures rather than silently failing. Action Text improved direct upload event handling, ensuring proper id and file properties in JavaScript events.

Additional infrastructure changes included freezing more immutable constants across the framework and fixing parameter filter optimizations for line-anchored regular expressions. The team reverted schema column sorting due to compatibility concerns and removed unused framework defaults files when load_defaults configurations match.

Development experience improvements included better renderable arity checks for overridden methods and enhanced only_columns behavior to properly enumerate SELECT statements.

One notable revert occurred for the ActiveModel::Conversion render_in implementation due to controller-based view partial namespacing issues, with a revised approach expected in future releases.

Looking ahead, expect continued database performance enhancements and potential refinements to the rendering system based on this week's learnings.

That's your Rails Daily weekly recap. Stay shipped.