1 -- Drop the old indexes
2 drop index idx_post_aggregates_newest_comment_time,
3 idx_post_aggregates_comments,
4 idx_post_aggregates_hot,
5 idx_post_aggregates_active,
6 idx_post_aggregates_score,
7 idx_post_aggregates_published;
9 -- All of the post fetching queries now start with either
10 -- featured_local desc, or featured_community desc, then the other sorts.
11 -- So you now need to double these indexes
13 create index idx_post_aggregates_featured_local_newest_comment_time on post_aggregates (featured_local desc, newest_comment_time desc);
14 create index idx_post_aggregates_featured_community_newest_comment_time on post_aggregates (featured_community desc, newest_comment_time desc);
16 create index idx_post_aggregates_featured_local_comments on post_aggregates (featured_local desc, comments desc);
17 create index idx_post_aggregates_featured_community_comments on post_aggregates (featured_community desc, comments desc);
19 create index idx_post_aggregates_featured_local_hot on post_aggregates (featured_local desc, hot_rank(score, published) desc, published desc);
20 create index idx_post_aggregates_featured_community_hot on post_aggregates (featured_community desc, hot_rank(score, published) desc, published desc);
22 create index idx_post_aggregates_featured_local_active on post_aggregates (featured_local desc, hot_rank(score, newest_comment_time) desc, newest_comment_time desc);
23 create index idx_post_aggregates_featured_community_active on post_aggregates (featured_community desc, hot_rank(score, newest_comment_time) desc, newest_comment_time desc);
25 create index idx_post_aggregates_featured_local_score on post_aggregates (featured_local desc, score desc);
26 create index idx_post_aggregates_featured_community_score on post_aggregates (featured_community desc, score desc);
28 create index idx_post_aggregates_featured_local_published on post_aggregates (featured_local desc, published desc);
29 create index idx_post_aggregates_featured_community_published on post_aggregates (featured_community desc, published desc);