• Yorick Peterse's avatar
    Use CTEs for nested groups and authorizations · ac382b56
    Yorick Peterse authored
    This commit introduces the usage of Common Table Expressions (CTEs) to
    efficiently retrieve nested group hierarchies, without having to rely on
    the "routes" table (which is an _incredibly_ inefficient way of getting
    the data). This requires a patch to ActiveRecord (found in the added
    initializer) to work properly as ActiveRecord doesn't support WITH
    statements properly out of the box.
    
    Unfortunately MySQL provides no efficient way of getting nested groups.
    For example, the old routes setup could easily take 5-10 seconds
    depending on the amount of "routes" in a database. Providing vastly
    different logic for both MySQL and PostgreSQL will negatively impact the
    development process. Because of this the various nested groups related
    methods return empty relations when used in combination with MySQL.
    
    For project authorizations the logic is split up into two classes:
    
    * Gitlab::ProjectAuthorizations::WithNestedGroups
    * Gitlab::ProjectAuthorizations::WithoutNestedGro...
    ac382b56
routable_spec.rb 6.14 KB