Disable joins for ApprovalRuleLike.group_users
What
Disable joins for ApprovalRuleLike.group_users
Why
With the introduction of Cells
we have to avoid cross-database joins of namespaces
and users
tables.
This commit users Rails' disable_joins
in order to perform multiple queries instead of joins.
As a result, by using disable_joins
on ApprovalRuleLike.group_users we accept the following trade-offs:
- We perform 4 smaller queries instead of 1 large query, one of which (Group) seems redundant
- From memory perspective, we load all the users anyway and now we additionally load their ids into memory from (group) members table, which is small overhead
- SELECT * FROM users ... WHERE id IN (1, 2...) is harder to parse, but we already load all users into memory, so from performance perspective, we don't introduce a lot of overhead
- When the
group_users
are preloaded, the queries are identical: #417459 (comment 1642583325)
Related issues:
Edited by Igor Drozdov