• 
      

    Speed up user search indexing by fixing query cache usage for profiles.

    Review Request #15013 — Created April 15, 2026 and submitted — Latest diff uploaded

    Information

    Review Board
    release-7.1.x

    Reviewers

    User.get_profile() has checks in place to make use of any profile
    fetched along with the user via select_related() or
    prefetch_related().

    In the case where the cached profile result is a None, we were falling
    back on default behavior based on the create_if_missing flag. This is
    fine if the flag is True (we want to create) but if the flag is
    False a redundant fetch would occur, which would likely still return a
    None result.

    This code now respects a None entry in the cache in this case, which
    will raise Profile.DoesNotExist as it would have before, but without
    the redundant database query.

    This will significantly speed up search indexing for users, which was
    performing 4 queries per user.

    Unit tests pass.

    Built new unit tests (for an upcoming change) that found this issue and
    verified the fix.

    Commits

    Files