N+1 query problem
- ORMs make it easy to a query per loop iteration, which we want to avoid
eager_load
- single query (left outer join)
- can reference the other table's columns in
where
preload
- a few queries (one per table)
- typically faster
N+1 query problem
eager_load
wherepreload
| #!/usr/bin/env ruby | |
| # | |
| # Ruby script to download a number of files | |
| # from individual URLs via HTTP/HTTPS/FTP | |
| # specified in an external file. | |
| # | |
| # Author: Tobias Preuss | |
| # Revision: 2013-04-18 16:26 +0100 UTC | |
| # License: Creative Commons Attribution-ShareAlike 3.0 Unported |
This is a compiled list of falsehoods programmers tend to believe about working with time.
Don't re-invent a date time library yourself. If you think you understand everything about time, you're probably doing it wrong.
| brew tap homebrew/versions | |
| brew install v8-315 | |
| gem install libv8 -v '3.16.14.13' -- --with-system-v8 | |
| gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315 | |
| bundle install |
First, add pry-rails to your Gemfile:
https://github.com/rweng/pry-rails
gem 'pry-rails', group: :developmentThen you'll want to rebuild your Docker container to install the gems
| FROM ruby:2.6.6-alpine | |
| ENV APP_PATH /var/app | |
| ENV BUNDLE_VERSION 2.1.4 | |
| ENV BUNDLE_PATH /usr/local/bundle/gems | |
| ENV TMP_PATH /tmp/ | |
| ENV RAILS_LOG_TO_STDOUT true | |
| ENV RAILS_PORT 3000 | |
| # copy entrypoint scripts and grant execution permissions |
| version: '3' | |
| networks: | |
| development: | |
| test: | |
| volumes: | |
| db_data: | |
| gem_cache: | |
| shared_data: | |
| services: | |
| restarone_redis: |
| #!/bin/sh | |
| # Configure homebrew permissions to allow multiple users on MAC OSX. | |
| # Any user from the admin group will be able to manage the homebrew and cask installation on the machine. | |
| # allow admins to manage homebrew's local install directory | |
| chgrp -R admin /usr/local | |
| chmod -R g+w /usr/local | |
| # allow admins to homebrew's local cache of formulae and source files | |
| chgrp -R admin /Library/Caches/Homebrew |