Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Pagination - The difference between model and query builder

In implementing-your-own-adapters:

Use a Phalcon\Mvc\Model\Resultset object as source data. Since PDO doesn’t support scrollable cursors this adapter shouldn’t be used to paginate a large number of records.

My question is does using the query builder help when retreving a large number of records (Say a few thousand).

Will using the query build adapter prevent a full table scan?

I'm sorry if this is garbled thinking and goes unanswered but besides the abilty to form your own query my mind is screaming why.



83.4k
Accepted
answer

Model adapter moves the cursor over the whole resultset to get the desired page when you ask for a specific page in the paginator. Meanwhile QueryBuilder uses a LIMIT/OFFSET clause to obtain the specified page without traversing a big resultset.