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

(Refactor) Normalize forum aggregates #4292

Draft
wants to merge 1 commit into
base: 8.x.x
Choose a base branch
from

Conversation

Roardom
Copy link

@Roardom Roardom commented Oct 30, 2024

Even though the queries were ultra efficient before (always less than 5ms), the total combined cpu execution time for forums is not greater than 0.3% of all total execution time. Opt for cleaner code and a normalized database instead.

In a forum with 40k posts and 5k topics:

Topic index: 26 ms -> 83ms.
The forum category topic index: 29 ms -> 63 ms.
The forum index: 20 ms -> 55 ms.
The forum topic index: 19 ms -> 25 ms.
User topics: 18 ms -> 21 ms.
Subscriptions: 19 ms -> 20 ms.

These numbers are very reasonable and normalization should be fine here.

Unfortunately, Laravel doesn't have a function for hasManyThrough()->latestOfMany() so the eager load has to be done manually.

TODO: topic reads

Even though the queries were ultra efficient before (always less than 5ms),
the total combined cpu execution time for forums is not greater than 0.3%
of all total execution time. Opt for cleaner code and a normalized database
instead.

In a forum with 40k posts and 5k topics:

Topic index: 26 ms -> 83ms.
The forum category topic index: 29 ms -> 63 ms.
The forum index: 20 ms -> 55 ms.
The forum topic index: 19 ms -> 25 ms.
User topics: 18 ms -> 21 ms.
Subscriptions: 19 ms -> 20 ms.

These numbers are very reasonable and normalization should be fine here.

Unfortunately, Laravel doesn't have a function for hasManyThrough()->latestOfMany() so the eager load has to be done manually.
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.

1 participant