]> Untitled Git - lemmy.git/blobdiff - migrations/2021-01-05-200932_add_hot_rank_indexes/up.sql
Adding stickied to post_aggregates.
[lemmy.git] / migrations / 2021-01-05-200932_add_hot_rank_indexes / up.sql
index a6c452340ccd1d049560c14a3ecb7140cb1057bd..f4d4147106429b4e938f500abc7951182daa9a2e 100644 (file)
@@ -12,15 +12,19 @@ end; $$
 LANGUAGE plpgsql
 IMMUTABLE;
 
--- Post
-create index idx_post_published on post (published desc);
-create index idx_post_stickied on post (stickied desc);
-
 -- Post_aggregates
+create index idx_post_aggregates_stickied_hot on post_aggregates (stickied desc, hot_rank(score, published) desc, published desc);
 create index idx_post_aggregates_hot on post_aggregates (hot_rank(score, published) desc, published desc);
+
+create index idx_post_aggregates_stickied_active on post_aggregates (stickied desc, hot_rank(score, newest_comment_time) desc, newest_comment_time desc);
 create index idx_post_aggregates_active on post_aggregates (hot_rank(score, newest_comment_time) desc, newest_comment_time desc);
+
+create index idx_post_aggregates_stickied_score on post_aggregates (stickied desc, score desc);
 create index idx_post_aggregates_score on post_aggregates (score desc);
 
+create index idx_post_aggregates_stickied_published on post_aggregates (stickied desc, published desc);
+create index idx_post_aggregates_published on post_aggregates (published desc);
+
 -- Comment
 create index idx_comment_published on comment (published desc);