Which is really faster?? To LAZY LOAD or to EAGER LOAD many associations w/ large data sets??? Because based on my research eager loading is faster because it queries all the data at once or minimizes the number of queries to be executed. But based on my experience why is lazy loading faster? Here is the scenario: users table have many posts and each posts has many comments and each comment has many author.
I dump many data in the tables in the database:
47 total rows in the users table
1305 total rows in the posts table
1138 total rows in the comments table
788 total rows in the authors table
Here is the benchmark:
BENCHMARKS
EAGER LOADING:
Loading Time: Base Classes 0.0216
Controller Execution Time ( Welcome / Eager ) 16.1154
Total Execution Time 16.1371
LAZY LOADING:
BENCHMARKS
Loading Time: Base Classes 0.0120
Controller Execution Time ( Welcome / Lazy ) 4.0325
Total Execution Time 4.0446
Subject: Eager loading vs Lazy loading
Which is really faster?? To LAZY LOAD or to EAGER LOAD many associations w/ large data sets??? Because based on my research eager loading is faster because it queries all the data at once or minimizes the number of queries to be executed. But based on my experience why is lazy loading faster? Here is the scenario: users table have many posts and each posts has many comments and each comment has many author.
I dump many data in the tables in the database:
47 total rows in the users table
1305 total rows in the posts table
1138 total rows in the comments table
788 total rows in the authors table
Here is the benchmark:
BENCHMARKS
EAGER LOADING:
Loading Time: Base Classes 0.0216
Controller Execution Time ( Welcome / Eager ) 16.1154
Total Execution Time 16.1371
LAZY LOADING:
BENCHMARKS
Loading Time: Base Classes 0.0120
Controller Execution Time ( Welcome / Lazy ) 4.0325
Total Execution Time 4.0446