Reduce DB load upon initial connection due to channel loading (#12500)
#### Lazily loading channels I've added a new RPC message called `SubscribeToChannels` that the client now sends when it first renders the channels panel. This causes the server to load the channels for that client and send updates to that client as channels are updated. Previously, the server did this upon connection. For backwards compatibility, the server will inspect clients' version, and continue to do this work immediately for old clients. #### Optimizations Running collab locally, I realized that upon connecting, we were running two concurrent transactions that *both* queried the `channel_members` table: one for loading your channels, and one for loading your channel invites. I've combined these into one query. In addition, we now use a join to load channels + members, as opposed to two separate queries. Even though `where id in` is efficient, it adds an extra round trip to the database, keeping the transaction open for slightly longer. Release Notes: - N/A
This commit is contained in:
parent
99901801f4
commit
279c5ab81f
8 changed files with 101 additions and 78 deletions
|
@ -159,6 +159,7 @@ message Envelope {
|
|||
SetChannelMemberRole set_channel_member_role = 123;
|
||||
RenameChannel rename_channel = 124;
|
||||
RenameChannelResponse rename_channel_response = 125;
|
||||
SubscribeToChannels subscribe_to_channels = 207; // current max
|
||||
|
||||
JoinChannelBuffer join_channel_buffer = 126;
|
||||
JoinChannelBufferResponse join_channel_buffer_response = 127;
|
||||
|
@ -250,7 +251,7 @@ message Envelope {
|
|||
TaskContextForLocation task_context_for_location = 203;
|
||||
TaskContext task_context = 204;
|
||||
TaskTemplatesResponse task_templates_response = 205;
|
||||
TaskTemplates task_templates = 206; // Current max
|
||||
TaskTemplates task_templates = 206;
|
||||
}
|
||||
|
||||
reserved 158 to 161;
|
||||
|
@ -1297,6 +1298,8 @@ message ChannelMember {
|
|||
}
|
||||
}
|
||||
|
||||
message SubscribeToChannels {}
|
||||
|
||||
message CreateChannel {
|
||||
string name = 1;
|
||||
optional uint64 parent_id = 2;
|
||||
|
|
|
@ -277,6 +277,7 @@ messages!(
|
|||
(ShareProjectResponse, Foreground),
|
||||
(ShowContacts, Foreground),
|
||||
(StartLanguageServer, Foreground),
|
||||
(SubscribeToChannels, Foreground),
|
||||
(SynchronizeBuffers, Foreground),
|
||||
(SynchronizeBuffersResponse, Foreground),
|
||||
(TaskContextForLocation, Background),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue