-
Notifications
You must be signed in to change notification settings - Fork 45
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
Search speed greatly reduced when using Counts.publish() #59
Comments
@Diginized, I've not benchmarked the publish-counts, but... This test seems to only load the initial data. publish-counts uses Does your test investigate latency in reactive updates? i.e. does the page respond more slowly when new docs are inserted that match the cursor's search parameters? May be difficult to check, but if no latency occurs on a reactive update, then it supports my theory that the problem is with You could also add another example to your test. If this also delays 0.5 - 2 seconds, then Meteor's Meteor.publish("search", function (searchParameters) {
cursor = Contacts.find(searchParameters);
//with Counts enabled, results have a lot of lag because it's blocking everything else form running.
counts = cursor.count();
return cursor;
}); If |
Other considerations:
Meteor.publish("search", function (searchParameters) {
cursor = Contacts.find(searchParameters);
//with Counts enabled, results have a lot of lag because it's blocking everything else form running.
counts = Contacts.find(searchParameters).count();
return cursor;
}); |
@boxofrox , you are correct, the lag I'm citing is only with the initial pageload of data. I think you are probably also correct about .count() being the slow part. Here's what I've learned:
I don't really understand the observer.added parts. This database doesn't change too often (very small number of users doing data input) so I'm not even as worried about the reactive updates or certain how to test them. Regarding Regex/denormalized: I've definitely thought about doing the denormalized names instead of regex searching, like you suggested, but so far the regex searching is working fast enough (when a count isn't happening) that I feel it's not causing any troubles. If the database gets into the 10s of millions of records then this is something I thought I might have to look into. Conclusion (for now): Your suggestion # 2 above (The fix described in issue #58 ) definitely has faster performance than any of the things discussed above. If you do make that change and allow the search values to pass through, I think that's a big help for performance. I have a feeling there will be a negative side-effect to it, which I'll note when I reply to that thread in a min, so maybe treating that behavior as an option is the best of all worlds. |
An Aside, to whom it may benefit: I'm doing three things with each search: displaying paged results, counting how many are displayed, and finally counting how many else are out there. I currently perform all of these things when the user hit's the "search" button, which is why I want it to be snappy. Another option that this conversation brought back to mind is that I could have an event listener on the various form fields that reactively updates parameters being passed to
|
FYI to better explain the
So what I meant was if publish-counts didn't use I plan to fix #58 before the week is out, but it will follow my work on #57. |
Makes sense. Thanks. |
Again, haven't read this closely, but I'll say two things (chime in if I can be more helpful):
What this does is put the publish in a separate "thread" and doesn't block other pubs. _There are edge cases if the sub stops before the count is done however_ (we should probably test these at some point). |
@tmeasday , thank you very much, both of these are really good to know. I actually missed that blocking was the default for publications (guess I haven't read as much of the docs as I thought!) That's part of why I'm now trying to mess with much larger test datasets, some of these things aren't really noticeable in the early stages. Both the Meteor.defer() and https://github.com/meteorhacks/unblock package are good to know about. I admit I'm still very used to SQL's case insensitivity, which I feel is really the more suitable default for searches/queries. Pre-processing and denormalizing Mongo data and making the database, and making it that much larger is going to take some getting used to. I assume that's really the only good suggestion out there (keep lowercase fields next to the originals),given what you're saying? But even if I were to do this, it still doesn't really help with the "I forget your full last name and think I might know the first few letters" scenario... which perhaps is best done via a typeahead/autocomplete system against an index. |
@Diginized denorming is pretty normal in mongo. But there are other options you could look at, like full text search.. |
First, thanks for creating this package, I was accomplishing some of this with custom method calls but this offers many handy features. I also find it much easier to use than the many others out there that seek to help with counts and paging.
The one downside is that it seems to add a lot of lag to my searches and it's doing so in a blocking (synchronous) fashion. I don't really care if the total count takes a second or two to respond, if it can run in the background and just update the template when it's ready. But holding up the rest of the app is a bummer. Is there's a way to get this to run asynchronously?
Example:
The following code executes and returns/displays 30 records to browser almost instantly (at most 5ms after button click)
The same code with Counts.publish() added is taking between .5 and 2 full seconds before the first signs of life are hitting the browser, and then things drop in sequentially (the total count from Counts.publish (y), then the count of records (x) on page (showing x of y records), then the records themselves)
Any suggestions on how to improve? Thanks again!
The text was updated successfully, but these errors were encountered: