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

fix: catalog items performance #5095

Merged
merged 1 commit into from
Apr 4, 2019

Conversation

mikemurray
Copy link
Member

@mikemurray mikemurray commented Apr 3, 2019

Resolves N/A
Impact: major
Type: performance

Issue

Catalog items query runs poorly with lots of media on variants and options.

Solution

Refactor resolver to ensure the primaryImage and media resolvers only run if requested.

Breaking changes

None.

Testing

  1. Add lots of products with lots of images using a special set of data. (you know the one)
  2. Run the catalogItems query with all variants and options
  3. See the query fast without the primaryImage and media
  4. Add the primaryImage and media and see the query slow down
{
  primaryShopId
  catalogItems(
    shopIds: ["cmVhY3Rpb24vc2hvcDpKOEJocTN1VHRkZ3daeDNyeg=="]
    tagIds:["cmVhY3Rpb24vdGFnOnRMc003SDVKSGRzWXlYZndE"]
    sortBy: createdAt,
    first: 20
  ) {
    edges {
      cursor
      node {
        _id
        ... on CatalogItemProduct {
          product {
            _id
            
            variants {
              _id
              primaryImage {
                URLs {
                  large
                  medium
                  small
                  thumbnail
                }
              }
              options {
                _id
                primaryImage {
                URLs {
                  large
                  medium
                  small
                  thumbnail
                }
            }
              }
                
          }
        }
      }
    } 
  }
}

Copy link
Contributor

@aldeed aldeed left a comment

Choose a reason for hiding this comment

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

I only reviewed code, but LGTM. Good find!

Copy link
Contributor

@spencern spencern left a comment

Choose a reason for hiding this comment

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

Drastically improves performance of catalogItemsQuery by only processing media and primaryImage of options and variants that request it in the query.

@spencern spencern merged commit 6b42e78 into develop Apr 4, 2019
@spencern spencern deleted the fix-mikemurray-catalog-items-performance branch April 4, 2019 00:45
Copy link
Member

@willopez willopez left a comment

Choose a reason for hiding this comment

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

:+1

@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.

4 participants