'SELECT queries giving timeout, UPDATE queries don't

For some reason our SELECT queries are timing out while our UPDATE queries don't. The only SELECT query that is working is with count(). All other queries are stuck and timeout with a 504 Gateway Timeout after 3600 seconds. Our company is having this issue for 2 days now and have absolutely no idea where this suddenly came from. Why would a count() work and * or ID not... When I execute queries locally, everything is working, but on the server it is not.

We are using PHP as our programming language:

  • Working: $db->query("SELECT count(*) as amount FROM emails WHERE processed='0'");
  • Timeout: $db->query("SELECT ID FROM emails WHERE processed='0'");
  • Timeout: $db->query("SELECT * FROM emails WHERE processed='0'");

I've also tried putting a limit on the queries to make sure the size of the result is not the reason of the problem.

EDIT: It looks like the size of the respons is the issue. If I do a LIMIT 1 with for example 5 columns, it is working, from the moment I add a 6th column in the SELECT it times out. The 5 columns are just some IDs and short strings.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source