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

Perf: Refactor ProductDrive#index with service #4845

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coalest
Copy link
Collaborator

@coalest coalest commented Dec 11, 2024

Doesn't resolve any ticket.

Description

The product drives index page was mentioned to be slow in production.

Turns out it we were running two aggregate queries for every product drive (for the item quantity and number of unique items).
So listing 10 product drives meant 20 queries just to calculate the totals.
Also this page isn't paginated, so that makes the issue worse. (Although it looks like it used to be?)

Type of change

  • Performance change (should be identical behavior for users)

How Has This Been Tested?

Passes test suite and tested locally.

Screenshots

The performance beforehand scales linearly with number of product drives, so the more i add the worse it got.

These screenshots are when ~10 product drives were being returned.
Before:
Screenshot from 2024-12-11 15-26-51

After:
Screenshot from 2024-12-11 15-27-21

@coalest coalest requested a review from dorner December 11, 2024 15:50
@cielf
Copy link
Collaborator

cielf commented Dec 11, 2024

I took a look at how product drives are distributed across organizations in prod -- it's very uneven, but about half a dozen organizations have more than 100, and one over 500 -- pagination isn't something they've asked for, but it may make sense. I'll throw it into the "inbox" for consideration.

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