The GetTeamsUnreadForUser call would be called for every team switch.
In CRT mode, it would make a separate store call for every team, which
would run the 3 aggregate SQL queries in GetThreadsForUser.

This is suboptimal because the complexity is linearly proportional
to the number of teams.

We make the following optimizations:
1. Change the query to a single one which aggregates all teams.
2. The query originally used just 2 out of the 3 queries, so one
query was fully redundant. We remove that query in the new one.
3. Further analysis was done whether it makes sense to run the 2
queries synchronously or not. The load-tests didn't show any degradation
in running them concurrently, so we keep the same behavior.

```release-note
NONE
```
Этот коммит содержится в:
Agniva De Sarker
2022-02-17 09:24:39 +05:30
коммит произвёл GitHub
родитель 9640962428
Коммит 6898b3d70f
8 изменённых файлов: 303 добавлений и 25 удалений

Просмотреть файл

@@ -179,6 +179,29 @@ func (_m *ThreadStore) GetPosts(threadID string, since int64) ([]*model.Post, er
return r0, r1
}
// GetTeamsUnreadForUser provides a mock function with given fields: userID, teamIDs
func (_m *ThreadStore) GetTeamsUnreadForUser(userID string, teamIDs []string) (map[string]*model.TeamUnread, error) {
ret := _m.Called(userID, teamIDs)
var r0 map[string]*model.TeamUnread
if rf, ok := ret.Get(0).(func(string, []string) map[string]*model.TeamUnread); ok {
r0 = rf(userID, teamIDs)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(map[string]*model.TeamUnread)
}
}
var r1 error
if rf, ok := ret.Get(1).(func(string, []string) error); ok {
r1 = rf(userID, teamIDs)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// GetThreadFollowers provides a mock function with given fields: threadID, fetchOnlyActive
func (_m *ThreadStore) GetThreadFollowers(threadID string, fetchOnlyActive bool) ([]string, error) {
ret := _m.Called(threadID, fetchOnlyActive)