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: update refresh spaces counters script #406

Merged
merged 5 commits into from
Jul 17, 2024

Conversation

ChaituVR
Copy link
Member

@ChaituVR ChaituVR commented Jul 12, 2024

Related to #406

Context: DIscussed on discord

@ChaituVR ChaituVR requested a review from wa0x6e July 12, 2024 06:48
@wa0x6e
Copy link
Contributor

wa0x6e commented Jul 12, 2024

The new approach was to avoid running one query per space, since it's the SELECT part that was slow.

Doing a SELECT FROM leaderboard for a single space was just a little faster than doing for thousands of space.

Approach will be:

  • Send a single SELECT GROUP BY space to select all vote_count for a lot of space at once
  • UPDATE space with the results from above query

Since the first query (SELECT) may be slow for big spaces, we can do 2 batches, one for verified spaces, and another one for non-verified spaces.

The SELECT query will look like

select SUM(leaderboard.vote_count), space from leaderboard JOIN spaces ON spaces.id = space   where spaces.verified = 1 GROUP by space 

@ChaituVR ChaituVR requested review from wa0x6e and removed request for wa0x6e July 16, 2024 09:21
Copy link
Contributor

@wa0x6e wa0x6e left a comment

Choose a reason for hiding this comment

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

tAck

@ChaituVR ChaituVR merged commit bc3686e into master Jul 17, 2024
2 checks passed
@ChaituVR ChaituVR deleted the fix-refresh-spaces-counter-script branch July 17, 2024 07:41
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