• 
      

    Optimize the query for Group and Repository.objects.accessible_ids().

    Review Request #11605 — Created May 12, 2021 and submitted

    Information

    Review Board
    release-3.0.x

    Reviewers

    This is a small query improvement to accessible_ids() that removes
    the usage of DISTINCT when querying a list of accessible IDs for
    Group and Repository. This means less work needed by the database,
    removing the usage of a temporary table on MySQL. Any de-duplication
    will now be done in Python, by converting to a set first.

    It's a small performance improvement setting the stage for some larger
    work on improving query performance.

    Both versions of accessible() still uses DISTINCT by default, but
    this can be turned off by passing distinct=False.

    Unit tests passed.

    Compared the EXPLAIN output between the two versions of the query
    on MySQL

    Summary ID
    Optimize the query for Group and Repository.objects.accessible_ids().
    This is a small query improvement that removes the usage of `DISTINCT` when querying a list of accessible IDs for `Group` and `Repository`. This means less work needed by the database, removing the usage of a temporary table on MySQL. Any de-duplication will now be done in Python, by converting to a `set` first. It's a small performance improvement setting the stage for some larger work on improving query performance.
    cc878e0a00163311c38837b214bd21aa64b1c980
    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (58e2b42)