Ruby on Rails

Ruby on Rails: Speed Demon Edition - 5x Faster Schema Loading

Today we're celebrating a massive performance win from andrewn617 at Shopify who just made Rails schema loading 5 times faster by batching SQL statements during table creation. Plus, Saidbek cleaned up some unused code in ActiveSupport's JSON decoding module, keeping our codebase tidy.

Duration: PT3M53S

https://podlog.io/listen/ruby-on-rails-87e2c2b6/episode/ruby-on-rails-speed-demon-edition-5x-faster-schema-loading-f43629bc

Transcript

Hey there, Rails developers! Welcome back to another episode of Ruby on Rails - your daily dose of what's happening in the framework we all love. I'm your host, and wow, do we have some exciting stuff to talk about today, March 19th, 2026.

You know that feeling when you're working on a big Rails app and you run your tests or boot up your development server, and you're just sitting there... waiting... for the schema to load? Well, grab your coffee because today's main story is going to make you very, very happy.

Let's dive right into the star of today's show - pull request 57000 from andrewn617 over at Shopify. This is one of those contributions that makes me genuinely excited about our community. Here's the story: they're working with a PostgreSQL database that has over a thousand tables. I know, I know - that sounds intense, but hey, that's the reality for a lot of us working on mature applications.

Now here's the kicker - their schema was taking 120 seconds to load. Two full minutes! That's enough time to make a sandwich, check your messages, maybe question some life choices. But andrewn617 wasn't having it. They dug into the problem and discovered that Rails was executing SQL statements one by one when creating tables during schema loading.

So what did they do? They implemented SQL statement batching. Instead of firing off each CREATE TABLE statement individually, Rails now collects all those statements and executes them in batches. The result? That same schema that took 120 seconds now loads in just 25 seconds. That's nearly five times faster!

This change touches the core database adapters - both PostgreSQL and MySQL - and includes proper test coverage. It's the kind of optimization that doesn't change how you write your code, but makes your entire development experience smoother. Jean Boussier merged this beauty, and I can already imagine developers around the world getting back precious minutes of their day.

Now, while we're talking about keeping things clean and efficient, let's give a quick shoutout to Saidbek for pull request 57008. It's a small but important housekeeping change - removing unused require statements from ActiveSupport's JSON decoding module. These kinds of contributions might not be flashy, but they're super valuable. Every unused require is a tiny bit of overhead we don't need, and maintaining clean, purposeful code makes Rails better for everyone.

I love seeing these different types of contributions side by side. You've got andrewn617 solving a real performance pain point they encountered in their work, and Saidbek taking the time to clean up code and reduce cruft. Both are essential to keeping Rails healthy and fast.

Today's Focus time! If you're working on a Rails application, especially one with a substantial database schema, this batching improvement is going to help you out automatically once it's released. But here's what you can do right now: take a look at your own schema loading times. Are they reasonable for your development workflow? If not, this might be a great opportunity to examine your database structure and see if there are optimizations you can make on your end too.

And hey, if you're feeling inspired by Saidbek's cleanup work, maybe spend a few minutes looking at your own codebase. Are there unused requires or other small bits of cruft you could clean up? Sometimes the most satisfying programming work is making things simpler and cleaner.

That's a wrap for today's episode! Keep building amazing things, keep contributing to the community, and remember - every line of code, whether it's a major performance boost or just cleaning up unused requires, makes Rails better for all of us. I'll catch you tomorrow with more Rails goodness. Happy coding!