Skip to content

unijewski/n-plus-1-workshop

Repository files navigation

N+1 queries problem workshop

This is an example app, showing the classic N+1 queries problem that is described in Rails guides.

Installation

  1. Make sure you have Ruby 3.0.3 installed.

  2. Clone the repository.

  3. Run bin/setup.

Generating sample data

To identify the problem, you need to generate some data. Run:

bundle exec rake generate_data N=1000

in order to insert 1000 rows of posts with associated records.

Things to do

Before diving into the problem, you should fix two small issues in the codebase.

To check them out, run rails notes or look at the entire checklist below.

Checklist

  • Fix associations between models when creating records in the rake task.
  • Display all posts on the /posts page in the following format: <b>first name from city:</b> body.
  • Visit the page and see what's happening. Logs will be useful.
  • Identify the performance problem and fix it. You can install bullet to get some help.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published