So I have a very basic, standard database query in my Laravel app:
$gameSales = SalesTracking::where('item_id', '=', $ga)->where('employee_id', '=', $employee->username)->where('username', '=', $username)->where('shift_id', '=', $sa)->where('status', '=', 'active')->get();
Granted, I have this query in a series of nested loops – but, for whatever reason, it seems that the "where('status', '=', 'active')" is causing the script to timeout.
In other words... when I have the following query (without the status = active):
$gameSales = SalesTracking::where('item_id', '=', $ga)->where('employee_id', '=', $employee->username)->where('username', '=', $username)->where('shift_id', '=', $sa)->get();
It completes and produces results within about 2-3 seconds.
As soon as I put that status = active query in however, it runs perpetually and eventually times out.
I have tried
- moving the position of it
- adjusting the statement (ie. status != 'inactive')
- retyping the query, thinking maybe I had a misspelling.
I just can't figure out why an extra query parameter would all of a sudden cause it to timeout.
Any ideas what I might be missing here?