I am using zend paginator for fetching records and listing the same.
There are four joins and I have indexed all the respective fields and I am getting only the required fields for listing in all the tables. Total number of records might be 5 million approx. I have tried to optimize the maximum and last I found this below code is best.
$select = new Zend_Paginator_Adapter_DbSelect($select);
$select->count($select);
$paginator = new Zend_Paginator($select);
But even with this, it takes more than 40sec to load the page. Can someone help me in getting better performance.
I will give little update to my question. below is my code
$query = $this->select();
$query->setIntegrityCheck(false);
$query->from(array('test1' => '*')))
->join(array('test2' => 'test2'), 'test2.id = test1.test2_id', array('*'))
->joinLeft(array('test3' => 'test3'), ("test1.test2_id = test3.test2_id'"), array('*')
->joinLeft(array('test4' => 'test4'), "test1.test4_id = test4.test4_id", array('*'))
->join(array('test5' => 'test5'), 'test1.test5_id = test5.id', array('*'));
$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbTableSelect($query));
$paginator->setItemCountPerPage(ITEM_PER_PAGE);
$paginator->setCurrentPageNumber($this->getRequest()->getParam('page', 1));
$paginator->setPageRange(PAGE_RANGE);
$this->view->paginator = $paginator;