An open API service indexing awesome lists of open source software.

https://github.com/shin4488/n-1-problem-solution


https://github.com/shin4488/n-1-problem-solution

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

          

# README

This README would normally document whatever steps are necessary to get the
application up and running.

Things you may want to cover:

* Ruby version

* System dependencies

* Configuration

* Database creation

* Database initialization

* How to run the test suite

* Services (job queues, cache servers, search engines, etc.)

* Deployment instructions

* ...

# note
docker compose build
docker compose run app rails new . --force --database=postgresql --skip-javascript
docker compose up -d app
docker compose exec app rails db:create
docker compose exec app rails db:migrate
docker compose exec app rails console

## Compare eager_load and preload

To see the SQL queries generated by `preload` and `eager_load` and measure
their execution time, run the following commands:

```bash
# run with a small dataset
bin/rails runner script/compare_load_methods.rb small

# run with a larger dataset
bin/rails runner script/compare_load_methods.rb large
```

The script sets up data using `DevDataStore`. For the small dataset, it
creates a handful of sample teams and players. For the large dataset it
generates **10,000 teams with 10,000 players each**, so be prepared for a long
runtime. Querying logic is provided by `Player.get_players_by_preload`,
`Player.get_players_by_eagerload`, `MlbTeam.get_teams_by_preload`, and
`MlbTeam.get_teams_by_eagerload`.