2 -- Populate the table using a different name.
3 CREATE TABLE recent_game_stats_mv_new AS
6 pgs.player_game_stat_id, g.game_id, g.server_id, g.map_id, p.player_id, p.nick, pgs.score, pgs.alivetime
8 FROM player_game_stats pgs
9 INNER JOIN players p USING (player_id)
10 INNER JOIN games g USING (game_id)
14 AND p.active_ind = true
15 AND pgs.create_dt BETWEEN (now() at time zone 'UTC' - interval '30 days') AND (now() at time zone 'UTC' + interval '1 day')
16 AND g.create_dt BETWEEN (now() at time zone 'UTC' - interval '30 days') AND (now() at time zone 'UTC' + interval '1 day');
19 CREATE INDEX recent_game_stats_mv_new_ix001 on recent_game_stats_mv_new(server_id);
20 CREATE INDEX recent_game_stats_mv_new_ix002 on recent_game_stats_mv_new(map_id);
22 -- Drop the old stuff, rename the stuff
23 DROP TABLE IF EXISTS recent_game_stats_mv CASCADE;
24 ALTER TABLE recent_game_stats_mv_new RENAME TO recent_game_stats_mv;
26 DROP INDEX IF EXISTS recent_game_stats_mv_ix001;
27 ALTER INDEX recent_game_stats_mv_new_ix001 RENAME to recent_game_stats_mv_ix001;
29 DROP INDEX IF EXISTS recent_game_stats_mv_ix002;
30 ALTER INDEX recent_game_stats_mv_new_ix002 RENAME to recent_game_stats_mv_ix002;