Pagination Optimization

From: Date: Fri, 07 Jan 2005 23:36:30 +0000
Subject: Pagination Optimization
Groups: php.general 
Request: Send a blank email to php-general+get-205856@lists.php.net to get a copy of this message
Hi guys, currently I have a function in my framework´s mysql driver , that fetch paginated results... Here it´s: =============================================================== /***************************************************** * Fetch paginated results *****************************************************/ function fetch_paginated($query='',$page=1,$itens=20) { $this->query($query.' LIMIT '.(($page*$itens)-$itens).','.$itens); if($this->num_rows() > 0) { while($this->fetch_array()) { $results[] = $this->row; } } else { return null; } $this->query($query.' LIMIT 0,'.(($page*$itens)-$itens)); $this->pages_before = ceil($this->num_rows()/$itens); $this->query($query.' LIMIT '.($page*$itens).',1000000000000000000'); $this->pages_after = ceil($this->num_rows()/$itens); $this->query($query); $this->total_pages = ceil($this->num_rows()/$itens); return $results; } =============================================================== My question is: Is there ANY way to speed up this function, or any way to fetch paginated results quicker? I had a project list, without pagination, and when I added the pagination function, it slowed down up to 0.0125 secs. Before it was running at 0.0600 more or less, and now it´s running at 0.07 to 0.075... Best Regards, Bruno B B Magalhães

« previous php.general (#205856) next »