Today I’m going to take a look at how ActiveRecord 3.1 implements prepared statements, and write a simple Ruby script that will display a log message each time your application takes advantage of them - so you’ll know how much love you need to show and the rest of the Rails core team! Taking a closer look at a Rails 3.1 log file without writing even a single line of code! That’s a really amazing achievement, and means that many of us will get a significant performance boost just by upgrading to Rails 3.1. With Rails 3.1, Aaron Patterson and the rest of the Rails core team managed to refactor ActiveRecord to create and cache prepared statements automatically without changing the existing ActiveRecord API. However, until now the Rails framework never supported using them. These “prepared statements” can be a great way to speed up frequently used SQL queries. But if you’re still using ActiveRecord with a traditional SQL database, like me, then you’re probably using one of Rails 3.1’s most powerful new features without even realizing it: Prepared Statements.ĭatabase servers such as Postgres and Oracle for years have allowed client applications to preprocess and cache specific SQL statement patterns ahead of time, later allowing the query results to be returned even faster. We’ve heard a lot about many of the great new features in Rails 3.1: the asset pipeline, Coffee Script, HTTP streaming and on and on. And the rest of the Rails core team deserve some love for speeding up your app!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |