Ruby on Rails

Ruby on Rails: PostgreSQL Performance Enhancements and Database Optimizations

Rails merged 15 pull requests focused on PostgreSQL improvements, including virtual column reloading via RETURNING clauses and new RETURNING statement support for INSERT/UPDATE/DELETE operations. Additional updates include ActiveStorage attach! method, strict loading fixes, and optimistic locking improvements.

Duration: PT1S

https://podlog.io/listen/ruby-on-rails-87e2c2b6/episode/ruby-on-rails-postgresql-performance-enhancements-and-database-optimizations-9534cd1b

Transcript

Good morning, I'm your host with the Ruby on Rails developer briefing for May 15th, 2026.

The Rails team merged 15 significant pull requests yesterday, with PostgreSQL performance taking center stage. Andrew Baldwin merged PostgreSQL reload virtual columns on update via RETURNING clause, eliminating extra database round trips by issuing single UPDATE queries with RETURNING clauses for virtual column reloads. This addresses a major developer pitfall around stale values.

Benedikt merged foundational RETURNING statement support for INSERT, UPDATE, and DELETE operations in Arel, enabling queries that modify and return data in a single operation. Sean Doyle updated Action Text to properly dispatch Active Storage events with required id and file properties, fixing missing direct upload events.

Several quality-of-life improvements landed: Quentin Demetz implemented the long-requested attach! method for ActiveStorage, providing the bang counterpart to attach for validation enforcement. Alexandre Camillo added array syntax support for expression indexes in add_index, allowing cleaner syntax like `["lower(email)", :status]` instead of raw SQL strings.

Performance optimizations include a fix for Hash and Array values during insert_all operations, delivering 1.8x speed improvements for serialized columns. The team also resolved strict loading violations being ignored when using pluck, and fixed lock_version reset issues after transaction rollbacks.

Additional updates include improved ParameterFilter hash-lookup optimization for line-anchored regexps, better handling of only_columns in SELECT statements, and frozen immutable constants across 16 files for memory optimization.

What's next: PostgreSQL users should see immediate performance benefits from the RETURNING clause implementations. The attach! method provides better error handling for file uploads.

That's your Rails update for today. Stay tuned for tomorrow's briefing.