Disable total entries
maxguzenski opened this issue · comments
Is there any plan to disable "select count(*)" by param?,
I use automatic pagination on my website, like facebook (when you research end of page, it load another one) and I'd like to not did 2 selects all the time.
my logic is:
get next page with 30 items
- if return exactly 30, maybe has a another page
- else isn't.
So, my client will make another ajax call only when last call returned exactly 30 items. It's a performace gain!
tip: I look you code, and you are calling total_entries before entries. You could test if entries returned less than page_size and just calculate total_entries. Will be 1 select less on last page ;)
This is not something I'll implement currently, but perhaps in the future.
Regarding your tip, the last page could have exactly the number of entries as the page size so it's not possible to determine the final page from the count of entries.
It's possible if you returned select has less than total entries. I know, it will happen rarely.
@drewolson In a high data volume application, count(*) is very slow. We need to support pagination without making global count query, so I second this request. To us, it's the difference between a query taking 100ms and 5s.
@egilburg as you're currently dealing with this issue, would you mind submitting a PR? Now that the ecto logic has been moved to a separate application, please submit any issues / PRs regarding ecto to scrivener_ecto.
@drewolson Sure, I can do that, what do you think would be the correct implementation, though? Pass total_pages: <int>
and/or total_pages: nil
, to override the count? Should it be part of Config module (part of scrivener
rather than scrivener-ecto
), or hardcoded as an extra param in the paginate
method of scrivener-ecto
's Paginater
implementation?
The more I think about this, the more I think the solution is to simply develop a separate implementation of the Scrivener.Paginator
for your use case. Essentially a new version of scrivener_ecto for your usecase. If you do end up building this, let me know and I'll gladly link to it from the README in this project.