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

Speed up the products table publication #5128

Merged
merged 3 commits into from
Apr 17, 2019
Merged

Conversation

aldeed
Copy link
Contributor

@aldeed aldeed commented Apr 16, 2019

Impact: minor
Type: performance

Issue

Loading and paging the products table in the operator UI is slow with large Products collection.

Solution

Results testing Mongo queries directly with 64654 top-level products:

Skip 0, no sorting: ~1ms
Skip 24000, no sorting: ~300ms
Skip 0, sort by createdAt: ~15ms
Skip 24000, sort by createdAt: ~1100ms

Sorting slows things down a bit as expected, but it is using the index so I don’t think there’s much to be done there. And 15ms query on the first page is respectable.

The query (without any fancy filtering) seems fine.

When I comment out the Counts.publish the table is much faster. So I think most of the blame is with publishing the count. We could look into using https://atmospherejs.com/natestrauser/publish-performant-counts package instead. But since we're soon moving this to GraphQL, I'd rather not introduce a new Meteor package.

For now, I'm seeing improvements by adding noReady and nonReactive options to the counts publication, and removing variants from the result set. We no longer need the variants included due to recent UI changes.

Other changes

With the variants no longer being published, this exposed an issue with the client side money formatting where there would end up being two currency symbols in the formatted string. I rewrote that function to use code similar to what we use on the server.

Breaking changes

None really but any custom plugins with operator UI components that are relying on variants being published might need updating.

Testing

Go to the Products table in operator UI with a large number of top-level products in the database. Verify that it loads in a few seconds and takes only a few seconds to switch between pages.

affecting admin products table prices

Signed-off-by: Eric Dobbertin <[email protected]>
@aldeed aldeed requested a review from mikemurray April 16, 2019 21:36
@aldeed aldeed self-assigned this Apr 16, 2019
Signed-off-by: Eric Dobbertin <[email protected]>
Copy link
Member

@mikemurray mikemurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial load is slow, most likely due to counting all 65k records I have in the database but every page load after that is fast, so... this looks good to me. 👍

@mikemurray mikemurray merged commit 91a9cb7 into develop Apr 17, 2019
@mikemurray mikemurray deleted the perf-aldeed-products-pub branch April 17, 2019 16:59
@jeffcorpuz jeffcorpuz mentioned this pull request Jul 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants