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

Improve performance of Taxon promotion rule #2258

Merged
merged 1 commit into from
Oct 4, 2017

Conversation

gmacdougall
Copy link
Member

  1. Before #actionable? was bringing all product ids of the rule's taxons
    from the database. On a particular case in a store with 1mil
    products, the promotion was bringing 0.6mil of them, with a query ~ 5sec
    and 5mil ids in Ruby.

    After, the exists? query is a milliseconds one.

  2. Before #eligible? was fetching all parent taxons of each taxon on a
    product, which is not required for the match process.

    So, given an order with 10 line items, with each line item having a
    product with 3 taxons, each of them having 2 parent taxons
    would mean 30 queries to the db to fetch the ancestors, bringing a
    total of 60 taxons in Ruby memory.

    All of them unnecessary, as the matching processes can be done solely
    based on the rule's taxons, which if 5 would mean 5 queries to the DB
    (self_and_descendants)

  3. Fix incorrect test on #eligible?#all for taxon child of a taxon rule
    case.

    • there were no children tested in the case
  4. On #eligible?#all, take only the IDs from the DB to
    reduce memory overhead

This is a rebased version of #1409

  1) Before #actionable? was bringing all product ids of the rule's taxons
     from the database. On a particular case in a store with 1mil
     products, the promotion was bringing 0.6mil of them, with a query ~ 5sec
     and 5mil ids in Ruby.

     After, the exists? query is a milliseconds one.

  2) Before #eligible? was fetching all parent taxons of each taxon on a
     product, which is not required for the match process.

     So, given an order with 10 line items, with each line item having a
     product with 3 taxons, each of them having 2 parent taxons
     would mean 30 queries to the db to fetch the ancestors, bringing a
     total of 60 taxons in Ruby memory.

     All of them unnecessary, as the matching processes can be done solely
     based on the rule's taxons, which if 5 would mean 5 queries to the DB
     (self_and_descendants)

  3) Fix incorrect test on #eligible?#all for taxon child of a taxon rule
     case.

     * there were no children tested in the case

  4) On #eligible?#all, take only the IDs from the DB to
     reduce memory overhead
@gmacdougall gmacdougall merged commit 3133604 into master Oct 4, 2017
@gmacdougall gmacdougall deleted the mtomov-improve-performance-of-taxon-rule branch October 4, 2017 21:29
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