|
| 1 | +--- |
| 2 | +layout: post |
| 3 | +title: "Routes Lookup Optimizations, PostgreSQL Alter Table improvements and more!" |
| 4 | +categories: news |
| 5 | +author: vipulnsward |
| 6 | +og_image: assets/images/this-week-in-rails.png |
| 7 | +published: true |
| 8 | +date: 2025-02-14 |
| 9 | +--- |
| 10 | + |
| 11 | +Hey everyone, Happy Friday! |
| 12 | + |
| 13 | +[Vipul](https://www.saeloun.com/team/vipul) here with the latest updates for This Week in Rails. |
| 14 | + |
| 15 | +This week, several improvements were made to Routes lookup. Below are a few notable changes- |
| 16 | + |
| 17 | +[Speed up GTG Simulator by reducing slices/matches](https://github.com/rails/rails/pull/54491) |
| 18 | +This change improves routing performance by 10-20% in simple cases by removing duplication and preventing excess string allocations. |
| 19 | + |
| 20 | +[Micro-Optimize Router#find_routes](https://github.com/rails/rails/pull/54517) |
| 21 | +This PR slightly improves the routes finding process by removing overheads and speeds up the route look up process by 2-2.5x faster compared to Rails 8.0. |
| 22 | + |
| 23 | +[Simplify stdparam state to reduce retained hashes](https://github.com/rails/rails/pull/54476) |
| 24 | +This PR simplifies the data stored in `stdparam_state` to be a simpler hash mapping and improving performance in hash intensive operations. |
| 25 | + |
| 26 | +Here's a list of other PRs with improvements around this area: [#54504](https://github.com/rails/rails/pull/54504), [#54491](https://github.com/rails/rails/pull/54491), [#54505](https://github.com/rails/rails/pull/54505), [#54515](https://github.com/rails/rails/pull/54515), [#54516](https://github.com/rails/rails/pull/54516), [#54526](https://github.com/rails/rails/pull/54526). |
| 27 | + |
| 28 | +[Allow execution wrapper to handle all exceptions](https://github.com/rails/rails/pull/54455/files) |
| 29 | +This PR changes the execution wrapper and execution middleware to default to catching all `Exception`s instead of all `StandardError`s. |
| 30 | + |
| 31 | +Essentially, before this change: |
| 32 | + |
| 33 | +```ruby |
| 34 | +Rails.error.handle do |
| 35 | + raise Exception |
| 36 | +end |
| 37 | +``` |
| 38 | +would not handle the exception, but now it does. |
| 39 | + |
| 40 | +[Make Value type default to mutable](https://github.com/rails/rails/pull/54435) |
| 41 | +This change makes the ActiveModel type values mutable by default, which in turn guarantees that custom type values are duplicated appropriately when modified. |
| 42 | + |
| 43 | +[Pass keyword arguments to PostgreSQL Adapter Table methods](https://github.com/rails/rails/pull/54472) |
| 44 | +With the use of forward argument `(...)` PostgreSQL adapter table definition methods can now accept keyword arguments. |
| 45 | +This change lays essential groundwork for `validate_constraint` and `validate_check_constraint` to start accepting keyword arguments. |
| 46 | + |
| 47 | +[Further restrict which contradicted queries need to be run](https://github.com/rails/rails/pull/54430) |
| 48 | +This change ensures that only fully matching queries trigger aggregation, ignoring mismatches and certain ARel values to avoid some additional queries. |
| 49 | + |
| 50 | +[Allow to skip HashWithIndifferentAccess value conversion](https://github.com/rails/rails/pull/54437) |
| 51 | +This PR addresses an inefficiency in ActiveModel’s handling of attribute changes, specifically when working with HashWithIndifferentAccess in serialized attributes. |
| 52 | + |
| 53 | + |
| 54 | +_You can view the whole list of changes [here](https://github.com/rails/rails/compare/@%7B2025-02-08%7D...main@%7B2025-02-14%7D)._ |
| 55 | + |
| 56 | +_We had [18 contributors](https://contributors.rubyonrails.org/contributors/in-time-window/20250208-20250214) to the Rails codebase this past week!_ |
| 57 | + |
| 58 | +Until next time! |
| 59 | + |
| 60 | +_[Subscribe](https://world.hey.com/this.week.in.rails) to get these updates mailed to you._ |
0 commit comments