reactioncommerce / reaction

Mailchimp Open Commerce is an API-first, headless commerce platform built using Node.js, React, GraphQL. Deployed via Docker and Kubernetes.
https://mailchimp.com/developer/open-commerce/
GNU General Public License v3.0
12.34k stars 2.17k forks source link

Accounts publication will be slow with lots of users #4448

Closed aldeed closed 6 years ago

aldeed commented 6 years ago

Issue Description

The "Accounts" Meteor publication, if you are a shop admin, sends every customer and guest account to the client upon loading the app in a browser / logging in as an admin. This will be very slow for large shops, and this data is not necessarily needed.

Related, and can be solved at the same time: https://github.com/reactioncommerce/reaction/issues/4277

Steps to Reproduce

  1. Make a bunch of accounts.
  2. Log in as an admin, and notice in the Meteor console extension that every account document is available in the browser.

Possible Solution

Find all client code that uses Accounts collection data for accounts other than the current user. Rewrite these places to do their own just-in-time subscription, getting only the data they need when they need it. (Or they can use a GraphQL query.)

Then update the "Accounts" publication to publish only the current user's account regardless of roles.

brent-hoover commented 6 years ago

@aldeed Are you sure this is still true of the most current version? @Akarshit put in a PR to not publish customer accounts to admin

aldeed commented 6 years ago

@zenweasel You're right, I was reading $nin as $in in the code.