so I'm currently using Zend Paginator b开发者_运维技巧ecause I'm having the impression that it doesn't ultimately use LIMIT x OFFSET y
or LIMIT x,y
queries and is therefore efficient even if I'm trying to seek page 99999 since LIMIT OFFSET would need to search through all items from the first one to the ones in page 99999 if I were to use LIMIT OFFSET...am I correct or incorrect in this assumption?
Yes, in the DbSelect and DbTableSelect adapters, Zend_Paginator sets LIMIT and OFFSET (or equivalent syntax, as determined by the Db Adapter). In both adapters, the following line appears:
...
$this->_select->limit($itemCountPerPage, $offset);
...
For more details, read the code in library/Zend/Paginator/Adapter/Db*Select.php.
You're right that a query with a large OFFSET runs slower in MySQL.
There are other techniques to optimize pagination.
See http://www.mysqlperformanceblog.com/2008/09/24/four-ways-to-optimize-paginated-displays/
Nope, Zend_Paginator ignores custom OFFSET in the query. So, if u use code like this:
Zend_Paginator::factory(..->select()->from('a', 'b')->where('c')->limit(5,1));
Zend_Paginator will ignore your offset. But u can create own adapter for the ZP.
p.s. version 1.11.10
精彩评论