I have mongodb and NodeJs. The connection is done via mongoosejs.
What is the best way to develop ajax infinity scroll ? Should I use limit and offset ?
I have mongodb and NodeJs. The connection is done via mongoosejs . What is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
“skip and limit” approach is not very efficient when you are paging far into dataset. It is effectively a Shlemiel the Painter’s algorithm.
Range queries are much more efficient (when supported by indexes). For example, let’s imagine that you’re displaying tweets. Your page size is 20 and you’re on page 1000 and want to load page 1001.
This query
is much less efficient than
(provided that you have index on
created_at).You get the idea: when you load a page, note the timestamp of the last tweet and use it to query the next page.