-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
N+1 Queries #72
Comments
That reversion seems simply due to the state for a tag not existing... which is a valid scenario if the user hasn't configured anything about the tags that use the user state. So not 100% sure why it was just reverted instead of adding a null check. Released v1.2.3 with this. Thanks! |
I'm now experiencing an issue with the subscription state on my forum with v1.2.3. On some tag pages, the subscription state is missing, but only on certain tags. Additionally, changing the follow status for these tags has no effect; the API returns null regardless of my selection: However, the I cannot reproduce this issue on a clean installation of Flarum. I checked on my forum with all extensions disabled except for Tags and Follow Tags, and the problem still persists. It might be related to the number of tags, above which the status does not load. I have 2544 tags in my database. I have tested everything and noticed that the API request query params includes Do you have any suggestions on what could be causing this issue? |
I have found the cause: flarum/framework#4007. |
This is interesting. I attempted a fix - can you see if #73 fixes all those instances for you? It should still improve performance over v1.2.3 (though not as much) |
This solves the problem, but the N+1 queries came back. For best performance, it would be worth fixing this problem directly in Flarum
|
I agree, but once it's fixed in Flarum it should be fine in follow tags. The queries made in that PR are less if the actor was the first to have a tag state created, I believe - or if they visit a tag directly I think. I'm not 100% sure of when the state passed is for the correct user, but I do believe at least it makes a few less queries sometimes. |
I pushed |
Bug Report
Current Behavior
When the extension is enabled, there are a lot of queries to the database when loading the discussion list.
This line is responsible for this:
follow-tags/src/AddTagSubscriptionAttribute.php
Line 23 in b76d70b
Steps to Reproduce
Expected Behavior
The subscription state should be eagerly loaded to minimize the number of database queries.
Screenshots
Environment
Additional Context
This issue was addressed in #45 but reverted in #46.
The text was updated successfully, but these errors were encountered: