Reduce unwanted queries in the Users and Groups datagrids.

Review Request #13422 — Created Nov. 15, 2023 and submitted — Latest diff uploaded

Information

Review Board
release-5.0.x

Reviewers

The Users and Groups datagrids both had extra queries conducted per-row,
some due to columns and some due to URL generation.

The Users datagrid was fetching associated review request counts
per-row. The Groups datagrid was fetching Local Sites (when applicable),
associated review request counts, and associated membership counts.

We now use a combination of column-specific and datagrid-specific
query augmentation to select-related or prefetch-related the queries we
need.

The Users datagrid tests have also been updated to ensure all profiles
are pre-created for the tests. This avoids an INSERT for each missing
profile. That may occur in the real world still, when importing users
who haven't logged in yet, but only the first time the profile is
accessed, so it's not worth optimizing around that.

Unit tests pass.

Tested the datagrids manually, making sure all columns and links still
work.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Reduce unwanted queries in the Users and Groups datagrids.
The Users and Groups datagrids both had extra queries conducted per-row, some due to columns and some due to URL generation. The Users datagrid was fetching associated review request counts per-row. The Groups datagrid was fetching Local Sites (when applicable), associated review request counts, and associated membership counts. We now use a combination of column-specific and datagrid-specific query augmentation to select-related or prefetch-related the queries we need. The Users datagrid tests have also been updated to ensure all profiles are pre-created for the tests. This avoids an INSERT for each missing profile. That may occur in the real world still, when importing users who haven't logged in yet, but only the first time the profile is accessed, so it's not worth optimizing around that.
22ebaaff23a56d4f84efb5899c8d83420d571698 Christian Hammond
reviewboard/datagrids/columns.py
reviewboard/datagrids/grids.py
reviewboard/datagrids/tests/test_groups_list.py
reviewboard/datagrids/tests/test_users_list.py
Loading...