Pagerfanta
Pagerfanta copied to clipboard
[RFC] Lazy adapters implementation
Use case: some databases/search engines aren't required execute two queries for getting count and slice. So we can use only one query for slice and count, but now it doesn't work properly, because Pagerfanta filters current page so early, before slice query executed.
For preventing +1 query I've created LazyAdapterInterface
that marks adapter as lazy.
TODO:
- [ ] documentation
- [x] tests
Example of lazy adapter for Sphinxsearch engine https://github.com/Koc/Sphinxy/blob/master/Pagerfanta/Adapter/SphinxyQbAdapter.php
Looks interesting for elasticsearch, too:
For example: I need aggregations from PagerfantaAdpter which are the same on all pages.
EDIT: Your PR is missing the actual LazyAdapterInterface
?
@mablae LazyAdapterInterface
is present, but it is empty. It is just mark adapter as lazy.
Tests have been added
Unfortunately the problem with double queries is still relevant.