N+1 queries problems in Tags API
Reported by @luzhiyuan.deer
Problem
-
When each Tag passes through
API::Entities::Tag
, the database tablereleases
will be queried
Related code: entities/tag.rb#L18
-
The cache time of tags is 1 day, so there is not a performance problem every time (of course this does not mean that this problem can not be taken seriously)
-
When using the
search
parameter, the query results are not paginated, which makes the N+1 queries problem worse. Our customer has 10,000+ tags, and the API occasionally takes 20 seconds ️
Proposal
Preload releases for Tags API calls to avoid a N+1 problem