When it comes to pagination, the simplest method that comes to mind is the skip-limit
, but it is not always the best solution!
skip-limit
Although theskip-limit
is suitable for some applications, it suffers from 2 major problems
As mentioned in MongoDB docs, it requires to scan all the previous docs before reaching the desired one, so it becomes slower as the offset increases. So the response times decline as page numbers increase.
The problem occurs meanwhile the user is exploring data and any doc being added or deleted simultaneously in the visited pages. it causes shifts in data which means we may face duplicated docs or not fetching some docs in the result. …