flarum / issue-archive

0 stars 0 forks source link

Eager loading in notifications endpoint #113

Open SychO9 opened 3 years ago

SychO9 commented 3 years ago

Split off from flarum/framework#2637

flarum lan___clockwork_app (9)

This is when hitting the endpoint /api/notifications?page[offset]=0&page[limit]=50&include=subject (extreme to be able to properly see uneager loaded relations).

There is improvement to be made, the difference between this endpoint and the others, is that the N+1 queries are mainly coming from the subject polymorphic relationship, for example subject.tags or subject.discussion.tags. Best way to go about it is to provide a loadMorph method to the ApiController extender to allow extensions (such as tags) to eager load the relations necessary.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We do this to keep the amount of open issues to a manageable minimum. In any case, thanks for taking an interest in this software and contributing by opening the issue in the first place!