update: various database performance improvements

Use eager loading where necessary and add a few indexes. The existing index on private_messages for sender_id and read was probably a typo and intended for receiver_id. The first 3 tables indexes are added to are used for queries ran on every page load: namely the new pm, new notification and warnings indicator in the navbar. Additionally, another index on genre_movie proved useful for finding all the genres when given a movie id. Perhaps, another index for finding all movies within a genre would be good as well, but will leave that for a future optimization if deemed necessary.
This commit is contained in:
Roardom
2023-07-16 23:01:29 +00:00
parent 70471626f8
commit b6b4313bdc
43 changed files with 148 additions and 142 deletions
@@ -38,7 +38,7 @@ class InviteController extends Controller
return view('user.invite.index', [
'user' => $user,
'invites' => $user->sentInvite()->withTrashed()->with(['sender', 'receiver'])->latest()->paginate(25),
'invites' => $user->sentInvite()->withTrashed()->with(['sender.group', 'receiver.group'])->latest()->paginate(25),
]);
}