Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query from minimongo of large number of records stucks and hangs browser #6216

Closed
MartiniHenry1988 opened this issue Feb 11, 2016 · 4 comments

Comments

@MartiniHenry1988
Copy link

I am building a page for admin in angular-meteor.

I have published all the records from a collection: "posts" and have taken the subscription of all the records on front end.

$meteor.subscribe('posts');

In the controller, if I select the cursors of all records from minimongo it works fine like:

$scope.posts = $meteor.collection(Posts);

But I want to display pagination, so for that I want limited records at a time like:

$scope.posts = $meteor.collection(function(){

        return Posts.find(

            {}, 
            {
                sort:   {'cDate.timestamp': -1},
                limit:  10
            }
        );
    });

It stucks with the query in minimongo. And the browser hangs.

"posts" collection contains only 500 records. It was working fine when I had 200 records.

Can anyone give me an idea whats wrong with my code and concepts?

EDIT:

Okay! It worked fine when I commented the $sort line from query like this:

$scope.posts = $meteor.collection(function(){

            return Posts.find(

                {}, 
                {
                    //sort:   {'cDate.timestamp': -1},
                    limit:  10
                }
            );
        });

But I need to sort the records. So what should I do now?

EDIT:

Also tried adding index to the sort attribute like this:

db.Posts.ensureIndex({"cDate.timestamp": 1})

Still same issue

@helfer
Copy link

helfer commented Feb 16, 2016

This could be due to minimongo's sort being inefficient, but it's hard to say without a minimal reproduction. Could you try to reproduce it with a minimal repo that contains just a dataset with ~500 records of the same size and doesn't actually render the data? That would help us figure out if it's minimongo or angular.

@MartiniHenry1988
Copy link
Author

It is the minimongo which downgrades the performance due to large number of records. You must keep limited records in minimongo otherwise it will take a lot of time to traverse it. So currently I am subscribing the limited amount of data from server. So now its fine

@abernix
Copy link
Contributor

abernix commented May 2, 2016

@hassansardarlecodeur MiniMongo doesn't currently support indexes which would probably help this substantially, but #5678 is open in order to track this.

@hwillson
Copy link
Contributor

As mentioned in #6216 (comment), without a reproduction this is difficult to help troubleshoot. It sounds like you found an acceptable solution by limiting the number of records you're pulling into minimongo, so I'll close this off. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants