includes vs. joins in Rails
includes
Eager load the included associations into memory. Fire two queries:
1 2 |
|
joins
Sometimes,includes
will load many redundant fields in association table, joins
help to control what columns after SELECT
.
Reference
- ruby - Rails :include vs. :joins - Stack Overflow
- #181 Include vs Joins - RailsCasts
- N+1 Benchmark Gist - IBM Developer Works
Does query with includes
and joins
return the same count?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Does includes
work with Mongoid?
Check list:
By now ( 2014-05-08 ) the latest version 4.0.0.beta1 behaves much better than last stable version 3.1.6, check the gist.