when I use Eloquent to retrieve data and find some performance issues
In my case, I use debugbar laravel ( https://github.com/barryvdh/laravel-debugbar ) to collect the information I need.
when i use ORM to get about 20 records from my db
$projects = Project::where('status', '=', 2)->get();
it took about 24 MB of memory and 250 ms
but when i use query builder as below
$projects = DB::table('Project')->where('status','=',2)->get();
database queries and returned data are almost the same, but the query builder used only 11 MB of memory and 113 ms to receive data.
when the required records occupy about 200 records and even relate to other tables via ORM, they take almost 8000 ms ... and often receive the "Allowed memory" error message.
So, I was interested, in my case, to use the query designer and join another table?
Or what should I do to speed up Eloquent?
source
share