Skip to content

Instantly share code, notes, and snippets.

@philiplambok
Created July 25, 2019 02:46
Show Gist options
  • Save philiplambok/fd5b685c61acf30685d15eb6b2c5d7ec to your computer and use it in GitHub Desktop.
Save philiplambok/fd5b685c61acf30685d15eb6b2c5d7ec to your computer and use it in GitHub Desktop.
history of improvement query.
 courses = Moodle::Course.taken_by(current_user)
 // Completed 200 OK in 161ms (Views: 0.2ms | ActiveRecord: 37.6ms
 // Completed 200 OK in 102ms (Views: 0.2ms | ActiveRecord: 31.1ms)
``

``rb
courses = Moodle::Course.includes(user_enrollments: [{ enrollments: [:courses] }]).taken_by(current_user)
// Completed 200 OK in 148ms (Views: 0.2ms | ActiveRecord: 37.4ms)
// Completed 200 OK in 109ms (Views: 0.1ms | ActiveRecord: 34.8ms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment