Phalcon slow page load - large table with querybuilder + paging


have been searching around on how phalcon handles large database and found below related info

I have tried the querybuilder for pagination and the page load quite some times (tested with 400k+ data - Mysql).

Sample controller as below. Is there any extra configuration need to be included? Is there any ways we can do this with partial page load instead whole page load?

Thanks guys

    public function indexAction()

     // Build query and Paginator
    $builder = $this->modelsManager->createBuilder()
        ->orderBy('ID DESC');

    $paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
        "builder" => $builder,
        "limit" => 20, // Or u can use some predefined value
        "page" => $this->request->getQuery('page', 'int')

    $this->view->page = $paginator->getPaginate();

    //echo "<pre>";
    echo json_encode($this->view->page->items->toArray());
    //echo "</pre>";

Maybe create an index on field id descendent could help.


Thanks Andres, after creating index on this table, the first load was excellent. But upon selecting Last paging, it seems the load time increase. Is this normal?