[AI assisted]: Improve system console statistics performance (#29899)
```release-note NONE ``` Co-authored-by: Matthew Birtch <mattbirtch@gmail.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6046a304b2
Коммит
ae9e6174e5
@@ -255,6 +255,8 @@ channels/db/migrations/mysql/000128_create_scheduled_posts.down.sql
|
||||
channels/db/migrations/mysql/000128_create_scheduled_posts.up.sql
|
||||
channels/db/migrations/mysql/000129_add_property_system_architecture.down.sql
|
||||
channels/db/migrations/mysql/000129_add_property_system_architecture.up.sql
|
||||
channels/db/migrations/mysql/000130_system_console_stats.down.sql
|
||||
channels/db/migrations/mysql/000130_system_console_stats.up.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.down.sql
|
||||
channels/db/migrations/postgres/000001_create_teams.up.sql
|
||||
channels/db/migrations/postgres/000002_create_team_members.down.sql
|
||||
@@ -511,3 +513,5 @@ channels/db/migrations/postgres/000128_create_scheduled_posts.down.sql
|
||||
channels/db/migrations/postgres/000128_create_scheduled_posts.up.sql
|
||||
channels/db/migrations/postgres/000129_add_property_system_architecture.down.sql
|
||||
channels/db/migrations/postgres/000129_add_property_system_architecture.up.sql
|
||||
channels/db/migrations/postgres/000130_system_console_stats.down.sql
|
||||
channels/db/migrations/postgres/000130_system_console_stats.up.sql
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- Nothing to do for MySQL
|
||||
@@ -0,0 +1 @@
|
||||
-- Nothing to do for MySQL
|
||||
@@ -0,0 +1,5 @@
|
||||
DROP MATERIALIZED VIEW IF EXISTS posts_by_team_day;
|
||||
|
||||
DROP MATERIALIZED VIEW IF EXISTS bot_posts_by_team_day;
|
||||
|
||||
DROP MATERIALIZED VIEW IF EXISTS file_stats;
|
||||
@@ -0,0 +1,16 @@
|
||||
CREATE MATERIALIZED VIEW IF NOT EXISTS posts_by_team_day as
|
||||
SELECT to_timestamp(p.createat/1000)::date as day, COUNT(*) as num, teamid
|
||||
FROM posts p JOIN channels c on p.channelid=c.id
|
||||
GROUP BY day, c.teamid;
|
||||
|
||||
CREATE MATERIALIZED VIEW IF NOT EXISTS bot_posts_by_team_day as
|
||||
SELECT to_timestamp(p.createat/1000)::date as day, COUNT(*) as num, teamid
|
||||
FROM posts p
|
||||
JOIN Bots b ON p.UserId = b.Userid
|
||||
JOIN channels c on p.channelid=c.id
|
||||
GROUP BY day, c.teamid;
|
||||
|
||||
CREATE MATERIALIZED VIEW IF NOT EXISTS file_stats as
|
||||
SELECT COUNT(*) as num, COALESCE(SUM(Size), 0) as usage
|
||||
FROM fileinfo
|
||||
WHERE DeleteAt = 0;
|
||||
Ссылка в новой задаче
Block a user