Tuesday, January 15, 2013

very slow response from CakePHP when performing a simple query

Hi there,

I am new to CakePHP and is trying to setup my first "Hello World" project. When working on that, I experienced a very slow response from CakePHP when performing a simple query to the DB.

Here are the steps that I have done:
  1. Download the CakePHP framework (2.3.0 RC1)
  2. Create a Test DB with an empty table named "tests" inside it.
  3. Edit the default AppController.php 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, it took more than 1 second to response. 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, the link http://localhost/app/say_hello only took around 60ms to response.

This doesn't seems right to me as performing a very simple query on an empty table should not take 940ms. I also tried doing the debug with DebugKit and it showed that more than 1s of time were spending on the ControllerAction which is pretty simple in this case. I am not what is causing the slowness of the response here.

Can any of the CakePHP experienced members shed me something on how to solve this slowness issue?

Thanks,

Quoc

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: