Sinnbeck's avatar

Sinnbeck wrote a reply+100 XP

5mos ago

Ok so everything related to the database. Seems like that is what you need to debug.

Perhaps start by explaining your setup

Sinnbeck's avatar

Sinnbeck wrote a reply+100 XP

5mos ago

Then the issues has nothing to do with the code you posted. Either the connection to the database or something elsewhere in your app. Do you have DB::listen() anywhere?

Is it slow if you do DB::table('users')->get()?

If that is also slow, is the database on an external server?

Sinnbeck's avatar

Sinnbeck wrote a reply+100 XP

5mos ago

Ok I feel you aren't really answering if a simple query is just as slow. Is this slow?

Route::get('test', function () {
    return User::all();
} 
Sinnbeck's avatar

Sinnbeck wrote a reply+100 XP

5mos ago

So User::all() is just as slow? What about another model? Same issue?

Sinnbeck's avatar

Sinnbeck wrote a reply+100 XP

5mos ago

You need to do some debugging here. Return just the users with User::all(). If that is also slow, you have some issues with your database set up. If it's slow to return a view without queries, it's nothing to do with the queries at all