Slow MySQL query and CPU Throttling

537 Views Asked by At

I host my CakePHP 1.3.x application on a shared host (hostmonster). I received a DNS errors from Google's webmasters tools and by contacting the technical support of my host, they indicated that there are CPU throttling occurs for my account and they guided me to check out this document about CPU Throttling.

From the above document, I checked tmp/mysql_slow_queries and I founded some queries takes more than 2 seconds and some of those queries are simple like:

# Sat Dec 14 02:00:38 2013
# Query_time: 3.286778  Lock_time: 0.000000 Rows_sent: 0  Rows_examined: 0
use twoindex_quran;
SET timestamp=1387011638;
SET NAMES utf8 

I need to know, why CakePHP applies a query such as SET timestamp and how could I prevent CakePHP to make such query. Also I need to know what's making such simple query slow?

1

There are 1 best solutions below

0
On

There are a few things that may be worth noting:

  1. You may need to upgrade CakePHP to use the PDO version of PHP MySQL connections since the older version of MySQL connect are being deprecated.

  2. Check the version of PHP your host is using. Make sure there is nothing strange between the host PHP version and the CakePHP PHP version requirements. Did the PHP version change recently causing these issues where they didn't exist before? If so, can you alter the .htaccess and use the previous version or did they cease to support it?

  3. A three second query should not cause a throttle condition on the host. The query information you are listing does not look like a CakePHP specific query. It looks like the PHP connection trying to connect to a specific database. There is nowhere in the code I know of that calls SET timestamp or SET names. Maybe someone can enlighten us on that?