Avoid too many User queries when calculating ReviewRequestPageData state.

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

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
Review request changed
Change Summary:

Updated for the recent changes to the unit tests.

Commits:
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.
371926ad05b6284d04767b181353991db15fdc95
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

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
david
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2.