mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 06:36:14 +00:00
Fixing slow joins to post_read, post_saved, and comment_saved . (#2738)
- Fixes #2445
This commit is contained in:
parent
9b0428bc50
commit
47f4aa3550
|
@ -311,7 +311,7 @@ impl<'a> CommentQuery<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.saved_only.unwrap_or(false) {
|
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) {
|
if !self.show_deleted_and_removed.unwrap_or(true) {
|
||||||
|
@ -325,7 +325,7 @@ impl<'a> CommentQuery<'a> {
|
||||||
|
|
||||||
if self.local_user.is_some() {
|
if self.local_user.is_some() {
|
||||||
// Filter out the rows with missing languages
|
// 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
|
// Don't show blocked communities or persons
|
||||||
query = query.filter(community_block::person_id.is_null());
|
query = query.filter(community_block::person_id.is_null());
|
||||||
|
|
|
@ -365,17 +365,17 @@ impl<'a> PostQuery<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if self.saved_only.unwrap_or(false) {
|
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
|
// 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.
|
// setting wont be able to see saved posts.
|
||||||
else if !self.local_user.map(|l| l.show_read_posts).unwrap_or(true) {
|
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() {
|
if self.local_user.is_some() {
|
||||||
// Filter out the rows with missing languages
|
// 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
|
// Don't show blocked communities or persons
|
||||||
query = query.filter(community_block::person_id.is_null());
|
query = query.filter(community_block::person_id.is_null());
|
||||||
|
|
|
@ -99,7 +99,8 @@ services:
|
||||||
"postgres",
|
"postgres",
|
||||||
"-c", "session_preload_libraries=auto_explain",
|
"-c", "session_preload_libraries=auto_explain",
|
||||||
"-c", "auto_explain.log_min_duration=5ms",
|
"-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:
|
networks:
|
||||||
- lemmyinternal
|
- lemmyinternal
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
drop index idx_post_saved_person_id, idx_comment_saved_person_id;
|
|
@ -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);
|
Loading…
Reference in a new issue