# How to Write Fast Code in Ruby on Rails

DevFeed: [How to Write Fast Code in Ruby on Rails](<https://devfeed.tech/articles/how-to-write-fast-code-in-ruby-on-rails-1680.md>)

Original publisher: [Read original article](<https://shopify.engineering/write-fast-code-ruby-rails>)

Author: Gannon McGibbon

Published: 2019-10-08T15:00:00Z

Content type: article

Language: en

Sources: [Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering.md>), [Shopify Engineering - Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering-shopify-engineering.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [Object-relational mapping](<https://devfeed.tech/topics/orm.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [SQL](<https://devfeed.tech/topics/sql.md>), [Databases](<https://devfeed.tech/topics/databases.md>), [Cache](<https://devfeed.tech/topics/cache.md>)

Tags: [blog-post](<https://devfeed.tech/tags/blog-post.md>), [cache](<https://devfeed.tech/tags/cache.md>), [code](<https://devfeed.tech/tags/code.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [orm](<https://devfeed.tech/tags/orm.md>), [performance](<https://devfeed.tech/tags/performance.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [shopify](<https://devfeed.tech/tags/shopify.md>), [sql](<https://devfeed.tech/tags/sql.md>)

## AI overview

This article explains techniques for writing faster code in Ruby on Rails, focusing on Active Record query performance. It covers when SQL is executed, selecting only needed data, and the limited persistence of Active Record's query cache.

## Source excerpt

Part of Shopify's success with Ruby on Rails is an emphasis on writing fast code. But, how do you really write fast code? Let's talk about a few ways to start writing faster code in Active Record, Rails, and Ruby.