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

Optimize total count of feed when loading activities in user dashboard. #33841

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lunny
Copy link
Member

@lunny lunny commented Mar 10, 2025

Two SQLs are very slow when action table have over 5M records.

database duration=1.8881s db.sql="SELECT created_unix DIV 900 * 900 AS timestamp, count(user_id) as contributions FROM `action` WHERE user_id=? AND act_user_id=? AND (created_unix > ?) GROUP BY timestamp ORDER BY timestamp"

database duration=1.5408s db.sql="SELECT count(*) FROM `action` WHERE (user_id = ?) AND (is_deleted = ?)"

This will cache the count for the first loading or when the activities changed.

@lunny lunny added the performance/speed performance issues with slow downs label Mar 10, 2025
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 10, 2025
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 10, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Mar 10, 2025
@github-actions github-actions bot removed the modifies/api This PR adds API routes or modifies them label Mar 10, 2025
@delvh
Copy link
Member

delvh commented Mar 10, 2025

created_unix DIV 900 * 900

Wait what? Why is this query so weird in the first place?

@lunny
Copy link
Member Author

lunny commented Mar 10, 2025

created_unix DIV 900 * 900

Wait what? Why is this query so weird in the first place?

This was introduced by #15252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/go Pull requests that update Go code performance/speed performance issues with slow downs size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants