We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon slow page load - large table with querybuilder + paging

Hi,

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

https://forum.phalcon.io/discussion/7303/phalcon-with-large-database

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()
        ->
        ->from("UserPortal")
        ->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.



703

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?