I am new to CakePHP framework and is trying to setup a "Hello World" project. When working on it, I experienced a very slow response from CakePHP when performing a simple DB query.
Here are the steps that I have done:
- Download the CakePHP framework (2.3.0 RC1) and have it setup
- Create a "Test" DB with an empty table named "Tests".
Edit the default AppController.php file as following:
class AppController extends Controller { var $uses = array('Test'); function say_hello() { $this->Test->query("select * from test where id=0"); echo "hello"; } }
After that, I accessed the link "http://localhost/app/say_hello" and it took more than 1s to respond.
If I commented out the query statement as following:
class AppController extends Controller {
var $uses = array('Test');
function say_hello() {
//$this->Test->query("select * from test where id=0");
echo "hello";
}
}
Then, it only took around 60ms to respond.
This doesn't seem right to me as performing a simple query on an empty table shouldn't take ~940ms. I have tried debuging with DebugKit and it showed that the ControllerAction (in this case, the say_hello action is pretty simple) was taking more than 1s of the processing time. Also note that the slowness issue was not caused by DB as DebugKit showed that there was only one query when executing the say_hello action and that query almost took 0ms to complete.
I am not sure what is causing such slowness. Can any experienced CakePHP members shed me some light on what's wrong in this case? What else I should do to troubleshoot and fix the issue?
Thanks.