0

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?

John Hubler
  • 843
  • 1
  • 10
  • 25
  • It might be worth your while to [get the raw SQL for your queries](https://stackoverflow.com/questions/18236294/how-do-i-get-the-query-builder-to-output-its-raw-sql-query-as-a-string), and run them through your database's query analyzer. Anything guesses we might make would be exactly that: guesses. – John Bollinger May 31 '22 at 21:18

0 Answers0