1 -- Drop the old indexes
2 DROP INDEX idx_post_aggregates_featured_local_hot;
4 DROP INDEX idx_post_aggregates_featured_local_active;
6 DROP INDEX idx_post_aggregates_featured_local_score;
8 DROP INDEX idx_post_aggregates_featured_community_hot;
10 DROP INDEX idx_post_aggregates_featured_community_active;
12 DROP INDEX idx_post_aggregates_featured_community_score;
14 DROP INDEX idx_comment_aggregates_hot;
16 DROP INDEX idx_comment_aggregates_score;
18 -- Add a published desc, to the end of the hot and active ranks
19 -- Add missing most comments index
20 CREATE INDEX idx_post_aggregates_featured_local_most_comments ON post_aggregates (featured_local DESC, comments DESC, published DESC);
22 CREATE INDEX idx_post_aggregates_featured_community_most_comments ON post_aggregates (featured_community DESC, comments DESC, published DESC);
25 CREATE INDEX idx_post_aggregates_featured_local_hot ON post_aggregates (featured_local DESC, hot_rank DESC, published DESC);
27 CREATE INDEX idx_post_aggregates_featured_local_active ON post_aggregates (featured_local DESC, hot_rank_active DESC, published DESC);
29 CREATE INDEX idx_post_aggregates_featured_local_score ON post_aggregates (featured_local DESC, score DESC, published DESC);
32 CREATE INDEX idx_post_aggregates_featured_community_hot ON post_aggregates (featured_community DESC, hot_rank DESC, published DESC);
34 CREATE INDEX idx_post_aggregates_featured_community_active ON post_aggregates (featured_community DESC, hot_rank_active DESC, published DESC);
36 CREATE INDEX idx_post_aggregates_featured_community_score ON post_aggregates (featured_community DESC, score DESC, published DESC);
38 -- Fixing some comment aggregates ones
39 CREATE INDEX idx_comment_aggregates_hot ON comment_aggregates (hot_rank DESC, published DESC);
41 CREATE INDEX idx_comment_aggregates_score ON comment_aggregates (score DESC, published DESC);