diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 1819c04db..be2e4cc85 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -311,7 +311,7 @@ impl<'a> CommentQuery<'a> { } if self.saved_only.unwrap_or(false) { - query = query.filter(comment_saved::id.is_not_null()); + query = query.filter(comment_saved::comment_id.is_not_null()); } if !self.show_deleted_and_removed.unwrap_or(true) { @@ -325,7 +325,7 @@ impl<'a> CommentQuery<'a> { if self.local_user.is_some() { // Filter out the rows with missing languages - query = query.filter(local_user_language::id.is_not_null()); + query = query.filter(local_user_language::language_id.is_not_null()); // Don't show blocked communities or persons query = query.filter(community_block::person_id.is_null()); diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 0804815df..88ff904b4 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -365,17 +365,17 @@ impl<'a> PostQuery<'a> { }; if self.saved_only.unwrap_or(false) { - query = query.filter(post_saved::id.is_not_null()); + query = query.filter(post_saved::post_id.is_not_null()); } // Only hide the read posts, if the saved_only is false. Otherwise ppl with the hide_read // setting wont be able to see saved posts. else if !self.local_user.map(|l| l.show_read_posts).unwrap_or(true) { - query = query.filter(post_read::id.is_null()); + query = query.filter(post_read::post_id.is_null()); } if self.local_user.is_some() { // Filter out the rows with missing languages - query = query.filter(local_user_language::id.is_not_null()); + query = query.filter(local_user_language::language_id.is_not_null()); // Don't show blocked communities or persons query = query.filter(community_block::person_id.is_null()); diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index f923c97d4..7ed15150c 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -99,7 +99,8 @@ services: "postgres", "-c", "session_preload_libraries=auto_explain", "-c", "auto_explain.log_min_duration=5ms", - "-c", "auto_explain.log_analyze=true" + "-c", "auto_explain.log_analyze=true", + "-c", "track_activity_query_size=1048576" ] networks: - lemmyinternal diff --git a/migrations/2023-02-15-212546_add_post_comment_saved_indexes/down.sql b/migrations/2023-02-15-212546_add_post_comment_saved_indexes/down.sql new file mode 100644 index 000000000..3ef1500c6 --- /dev/null +++ b/migrations/2023-02-15-212546_add_post_comment_saved_indexes/down.sql @@ -0,0 +1 @@ +drop index idx_post_saved_person_id, idx_comment_saved_person_id; diff --git a/migrations/2023-02-15-212546_add_post_comment_saved_indexes/up.sql b/migrations/2023-02-15-212546_add_post_comment_saved_indexes/up.sql new file mode 100644 index 000000000..889943121 --- /dev/null +++ b/migrations/2023-02-15-212546_add_post_comment_saved_indexes/up.sql @@ -0,0 +1,2 @@ +create index idx_post_saved_person_id on post_saved (person_id); +create index idx_comment_saved_person_id on comment_saved (person_id);