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

[CPDNPQ-2395] improve participants API load times #2101

Merged
merged 3 commits into from
Jan 13, 2025

Conversation

alkesh
Copy link
Contributor

@alkesh alkesh commented Jan 3, 2025

Context

Ticket: https://dfedigital.atlassian.net/browse/CPDNPQ-2395

requests to /api/v3/participants/npq?page_size=3000&updated_since=2020-01-01 are too slow (~800ms)

Changes proposed in this pull request

  • switch to pagy_countless (saves 200-300ms)
  • add index to applications lead_provider_approval_status (saves ~100ms)
  • add index to users created_at (saves ~200ms)

Tested using a production data dump, using lead provider Ambition Institute, which has ~46,000 users.

before optimisation: page load ~800ms
after optimisation: page load ~150ms

Copy link
Contributor

github-actions bot commented Jan 3, 2025

@alkesh alkesh marked this pull request as ready for review January 3, 2025 16:28
@alkesh alkesh requested a review from a team as a code owner January 3, 2025 16:28
@@ -10,7 +10,7 @@ module Pagination
private

def paginate(scope)
_pagy, paginated_records = pagy(scope, limit: per_page, page:)
_pagy, paginated_records = pagy_countless(scope, limit: per_page, page:)
Copy link
Member

Choose a reason for hiding this comment

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

TIL about Pagy::Countless 💡

Copy link
Member

@peteryates peteryates left a comment

Choose a reason for hiding this comment

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

Looks good 🔥

@alkesh alkesh changed the title [CPDNPQ-2395] improve participants api load times [CPDNPQ-2395] improve participants API load times Jan 6, 2025
Copy link
Contributor

@jebw jebw left a comment

Choose a reason for hiding this comment

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

LGTM - page_countless should have a massive impact across the board

@alkesh alkesh added this pull request to the merge queue Jan 13, 2025
Merged via the queue into main with commit 279ddfe Jan 13, 2025
18 checks passed
@alkesh alkesh deleted the CPDNPQ-2395-improve-participants-api-load-times branch January 13, 2025 16:18
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.

3 participants