• Yorick Peterse's avatar
    Cache the number of open issues and merge requests · 6ec53f5d
    Yorick Peterse authored
    Every project page displays a navigation menu that in turn displays the
    number of open issues and merge requests. This means that for every
    project page we run two COUNT(*) queries, each taking up roughly 30
    milliseconds on GitLab.com. By caching these numbers and refreshing them
    whenever necessary we can reduce loading times of all these pages by up
    to roughly 60 milliseconds.
    
    The number of open issues does not include confidential issues. This is
    a trade-off to keep the code simple and to ensure refreshing the data
    only needs 2 COUNT(*) queries instead of 3. A downside is that if a
    project only has 5 confidential issues the counter will be set to 0.
    
    Because we now have 3 similar counting service classes the code
    previously used in Projects::ForksCountService has mostly been moved to
    Projects::CountService, which in turn is reused by the various service
    classes.
    
    Fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/36622
    6ec53f5d
issue.rb 8.73 KB