Thanks for the response. You might want to know that the query timeout doesn't seem to work in my case: here is a screenshot from the process list showing a counting query at 99 seconds (different database than my earlier example of course). Please let me know if I can help diagnose.
I am using MySQL version: 10.0.20-MariaDB-log through PHP extension MySQL and PHP Version 5.6.11
SELECT executes unnecessary COUNT(*) query