MM-45956: Optimize FileInfo stats query (#22603)
* MM-45956: Optimize FileInfo stats query We Denormalize Post.ChannelId on FileInfo.ChannelId ```release-note The file info stats query is now optimized by denormalizing the channelID column into the table itself. This will speed up the query to get the file count for a channel on clicking the RHS. Migration times: On a MySQL 8.0.31 DB with 1405 rows in FileInfo and 11M posts, it took around 0.3s On a Postgres 12.14 DB with 1731 rows in FileInfo and 11M posts, it took around 0.27s ``` https://mattermost.atlassian.net/browse/MM-45956
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1edbde8aa3
Коммит
56b18ca7bf
@@ -36,10 +36,14 @@ type GetFileInfosOptions struct {
|
||||
}
|
||||
|
||||
type FileInfo struct {
|
||||
Id string `json:"id"`
|
||||
CreatorId string `json:"user_id"`
|
||||
PostId string `json:"post_id,omitempty"`
|
||||
ChannelId string `db:"-" json:"channel_id"`
|
||||
Id string `json:"id"`
|
||||
CreatorId string `json:"user_id"`
|
||||
PostId string `json:"post_id,omitempty"`
|
||||
// ChannelId is the denormalized value from the corresponding post. Note that this value is
|
||||
// potentially distinct from the ChannelId provided when the file is first uploaded and
|
||||
// used to organize the directories in the file store, since in theory that same file
|
||||
// could be attached to a post from a different channel (or not attached to a post at all).
|
||||
ChannelId string `json:"channel_id"`
|
||||
CreateAt int64 `json:"create_at"`
|
||||
UpdateAt int64 `json:"update_at"`
|
||||
DeleteAt int64 `json:"delete_at"`
|
||||
|
||||
Ссылка в новой задаче
Block a user