Skip to content

Search speed greatly reduced when using Counts.publish() #59

@R3Shift

Description

@R3Shift

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)

    Meteor.publish("search", function (searchParameters) {
        cursor = Contacts.find(searchParameters); 
        //with Counts disabled, results on screen feel instant. 
        //counts = Counts.publish(this, 'totalSearchResultsCounter', Contacts.find(searchParameters));
        return cursor;   
    });

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)

    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 = Counts.publish(this, 'totalSearchResultsCounter', Contacts.find(searchParameters));
        return cursor;   
    });

Any suggestions on how to improve? Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions