$27

Fix n+1 queries on Rails

0 ratings
I want this!

Fix n+1 queries on Rails

$27
0 ratings

Learn different ways to solve n+1 queries beyond "includes", to be confident that you can handle tasks on complex data models and fix n+1 queries if they appear.

Making things work isn't enough for you any more?

Do you feel or maybe your boss have told you directly that now you need to consider performance and scalability?

Do you feel unqualified to tackle complex tasks?

Do you still have troubles fixing some n+1 queries?

Do you have problems trying to find why active record is ignoring your "includes"?

Maybe you know the basics...

Maybe you know how to fix some n+1 queries and use "preload" or "includes" here and there, but...

Do you worry when they ask you for more?

"Can you preload just an scope?"

"Can you change the implementation to preload via has many through?"

"Shoud we use a counter cache or just preload the counts?"

"Can you persist the calculation?... just please be aware of race conditions!"

"That fix to the n+1 queries, will hurt the performance... we need to try something else"

But, what if you could...

Ship code that fix user problems taking performance in consideration.

Be confident that you can handle tasks on complex data models.

Fix n+1 queries in the best way possible taking into account different angles.

Be one of those who help the team... next week

Learn how to fix n+1 queries on rails

Start your road to fix n+1 queries like a pro, with my ebook Fix n+1 queries on rails:

  • Forget about… “Why active record is ignoring my includes?”
  • Learn different ways to solve n+1 queries beyond includes
  • Learn different preloading techniques to avoid n+1 queries
  • Learn how to count records without n+1 queries
  • Learn to use counter caches
  • Learn how to cash custom counts and other computed values with concurrency in mind

Table of contents

Here is the full table of contents of the book.

1. No more… “Why active record is ignoring my includes?”

  • Explain what is an n+1 queries problem
  • Identify when ActiveRecord will execute a query
  • Solve the latest comment example
  • Detect n+1 queries by watching the logs
  • Tools to detect n+1 queries

2. Use preloading to avoid n+1 queries

  • Joins does not preload
  • Preload direct associations
  • Preload nested associations
  • Difference between preload, eager load or includes
  • I prefer to use preload by default
  • Preload scopes with scoped associations
  • Simplify preloading with has many through associations
  • Use a “preload object” for complex preloading
  • Sometimes preloading can hurt the performance

3. Count without n+1 queries

  • What is the difference between count, size and length
  • Common mistakes with counts
  • How to preload counts in a list

4. Save counts with counter caches

  • Add counter cache to a new association
  • Custom counter cache columns names
  • Reset the counters for an existent association with just a few records
  • Reset the counters with SQL, for associations with many records
  • Using counter caches in your views

5. Caching custom counts and other computed values

  • Fix n+1 queries by caching computed values
  • Be aware that you can save incorrect values due to race conditions
  • Tips to avoid race conditions saving computed values
Sorry, the discount code you wish to use is invalid.
I want this!

An ebook to help you go from "Please help me with my n+1 problem" to be one of those that can help the team.

Pages
83
Copy product URL