-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
PostRepository::getIndexForNumber() walks 2 time the posts table to get offset #3895
Comments
I wonder why flarum introduced the number column on the post table as it can't be trusted because posts can be deleted and there is already the id/created_at attributes to provide post ordering ? |
Hi there, this looks like something I might be able to fix, could I please be assigned? Thankyou |
As a side note, my proposed solution was to add indexes, but I didn't understood at the time the database structure and the execution plan output. If I understand correctly, Mysql is already using the following two indexes:
to skip unrelated posts, that's why the whole This function seems to be called in order to retrieve the current offset of unread post within a discussion. I wonder if it might be preferable to save for each discussion/user combination:
And replace deleted posts with a message flagging the post as such in order to keep the following posts OR Each time a post is deleted, for each discussion/user combination, decrease the associated |
@Spencer-Robertson-ANU How is it going ? |
A few comments here. From mobile so I might leave out or miss a few details. First of we don't do assignment of issues unless you are a core developer. You could have provided a proposed solution and a pull request for us to review. Secondly. Storing the post Id seems like a valid solution, but post Ids aren't sequences. I think introducing this into the last read state of a user would be detrimental and updating all user states upon deletion will be a big hit on performance for communities with millions of users. Thirdly, thank you for the amazing amount of research on this topic @DavidKeller. I do feel this needs our attention, at least for 2.x. |
In our case, we don't have that many users, but big topics where the current design causes delays up to multiple seconds. But I get your point. What about the first proposal, that is not really deleting post, but flagging them as deleted instead in order to keep a valid |
Current Behavior
When showing discussion with a large number of posts, flarum pressures the database when calling
with the following SQL request:
which results in the following execution plan on MariaDB:
As you can see on the
rows
column from the last snippet: the posts table is scanned two times in order to retrieve only an offset.Steps to Reproduce
Create a discussion with a large number of posts (> 50K).
Display it.
Expected Behavior
Expect the display duration to be agnostic of the number of posts within the discussion.
Screenshots
No response
Environment
Output of
php flarum info
Possible Solution
Indexes ?
Additional Context
_No response_je
The text was updated successfully, but these errors were encountered: