Mongoid queries are fast. For example if it a query which returns 300 documents takes about 10 miliseconds but if I do
to_a or entries to get the results takes time.
Is there any other way to reduce the time lag.
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.
I haven’t look at the source code yet, but Mongoid queries are lazily evaluated.
Which means, your first call to the criteria does not touch the database, and Mongoid actually really fetch the data when you do ‘to_a’ or ‘entries’ hence the time lag.