• 
      

    Avoid too many User queries when calculating ReviewRequestPageData state.

    Review Request #14316 — Created Jan. 30, 2025 and submitted

    Information

    Review Board
    release-7.1.x

    Reviewers

    We query a lot of objects in ReviewRequestPageData, and many of these
    have User objects associated. These end up being queried as separate
    instances, which means that we lose out on any caching of profiles. This
    ultimately leads to a lot of extra SQL queries per page.

    We now determine all the users we know we have up-front, and then query
    for for anything we're missing. Once we know we have all the users, we
    re-attach the instances to the fetched objects, allowing the same
    instances and cached state to be reused.

    Unit tests pass.

    Verified that the SQL queries on some test review requests have been
    reduced.

    Summary ID
    Avoid too many User queries when calculating ReviewRequestPageData state.
    We query a lot of objects in `ReviewRequestPageData`, and many of these have `User` objects associated. These end up being queried as separate instances, which means that we lose out on any caching of profiles. This ultimately leads to a lot of extra SQL queries per page. We now determine all the users we know we have up-front, and then query for for anything we're missing. Once we know we have all the users, we re-attach the instances to the fetched objects, allowing the same instances and cached state to be reused.
    6a5049fa4e2b6c3cfc3977254a9da178253945bf
    chipx86
    david
    1. Ship It!
    2. 
        
    maubin
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-7.1.x (34bc421)