Repository navigation
Updates filter for excluding thread statuses - #4054
Merged
Merged
Conversation
Member
Author
|
This fixes a bug in which a reply to a status on a blocked book might still appear in a timeline, but I gotta say I just hit on that by accident. I don't think it meaningfully changes the performance of the query (which is what I was trying to do), but it's slightly better. Running this against production, before: Bitmap Heap Scan on bookwyrm_user (cost=907.88..308728.55 rows=3831 width=1477) (actual time=27.342..153.303 rows=29205 loops=1)
Recheck Cond: (local AND is_active)
Filter: ((NOT (ANY (id = (hashed SubPlan 1).col1))) AND (NOT (ANY (id = (hashed SubPlan 4).col1))) AND (NOT (ANY (id = (hashed SubPlan 3).col1))))
Rows Removed by Filter: 1
Heap Blocks: exact=21303
-> Bitmap Index Scan on bookwyrm_us_local_40fe61_idx (cost=0.00..826.94 rows=30652 width=0) (actual time=4.870..4.871 rows=29206 loops=1)
Index Cond: ((local = true) AND (is_active = true))
SubPlan 1
-> Nested Loop (cost=0.70..16.74 rows=1 width=4) (actual time=0.027..0.029 rows=0 loops=1)
-> Index Only Scan using userblocks_unique on bookwyrm_userblocks u1 (cost=0.28..8.29 rows=1 width=4) (actual time=0.027..0.027 rows=0 loops=1)
Index Cond: (user_subject_id = 227768)
Heap Fetches: 0
-> Index Only Scan using bookwyrm_user_pkey on bookwyrm_user u0 (cost=0.42..8.44 rows=1 width=4) (never executed)
Index Cond: (id = u1.user_object_id)
Heap Fetches: 0
SubPlan 4
-> Nested Loop (cost=4.66..63.21 rows=10 width=4) (actual time=0.489..0.492 rows=1 loops=1)
-> Bitmap Heap Scan on bookwyrm_user_blocked_books u1_2 (cost=4.23..14.79 rows=10 width=4) (actual time=0.271..0.272 rows=1 loops=1)
Recheck Cond: (work_id = 6644)
Heap Blocks: exact=1
-> Bitmap Index Scan on bookwyrm_user_blocked_books_work_id_b838f8eb (cost=0.00..4.23 rows=10 width=0) (actual time=0.011..0.012 rows=1 loops=1)
Index Cond: (work_id = 6644)
-> Index Only Scan using bookwyrm_user_pkey on bookwyrm_user u0_1 (cost=0.42..4.84 rows=1 width=4) (actual time=0.024..0.024 rows=1 loops=1)
Index Cond: (id = u1_2.user_id)
Heap Fetches: 0
SubPlan 3
-> Index Scan using bookwyrm_userblocks_user_object_id_ff33ba18 on bookwyrm_userblocks u1_1 (cost=0.28..8.29 rows=1 width=4) (actual time=0.103..0.104 rows=1 loops=1)
Index Cond: (user_object_id = 227768)
Planning Time: 2.861 ms
JIT:
Functions: 50
Options: Inlining false, Optimization false, Expressions true, Deforming true
Timing: Generation 2.182 ms (Deform 1.177 ms), Inlining 0.000 ms, Optimization 1.568 ms, Emission 17.173 ms, Total 20.923 ms
Execution Time: 177.124 ms
(34 rows)And after: Bitmap Heap Scan on bookwyrm_user (cost=845.60..308666.28 rows=7663 width=1477) (actual time=20.220..121.201 rows=29205 loops=1)
Recheck Cond: (local AND is_active)
Filter: ((NOT (ANY (id = (hashed SubPlan 1).col1))) AND (id <> 179036) AND (NOT (ANY (id = (hashed SubPlan 3).col1))))
Rows Removed by Filter: 1
Heap Blocks: exact=21303
-> Bitmap Index Scan on bookwyrm_us_local_40fe61_idx (cost=0.00..826.94 rows=30652 width=0) (actual time=3.246..3.247 rows=29210 loops=1)
Index Cond: ((local = true) AND (is_active = true))
SubPlan 1
-> Nested Loop (cost=0.70..16.74 rows=1 width=4) (actual time=0.020..0.021 rows=0 loops=1)
-> Index Only Scan using userblocks_unique on bookwyrm_userblocks u1 (cost=0.28..8.29 rows=1 width=4) (actual time=0.019..0.019 rows=0 loops=1)
Index Cond: (user_subject_id = 227768)
Heap Fetches: 0
-> Index Only Scan using bookwyrm_user_pkey on bookwyrm_user u0 (cost=0.42..8.44 rows=1 width=4) (never executed)
Index Cond: (id = u1.user_object_id)
Heap Fetches: 0
SubPlan 3
-> Index Scan using bookwyrm_userblocks_user_object_id_ff33ba18 on bookwyrm_userblocks u1_1 (cost=0.28..8.29 rows=1 width=4) (actual time=0.178..0.179 rows=1 loops=1)
Index Cond: (user_object_id = 227768)
Planning Time: 0.406 ms
JIT:
Functions: 34
Options: Inlining false, Optimization false, Expressions true, Deforming true
Timing: Generation 1.326 ms (Deform 0.692 ms), Inlining 0.000 ms, Optimization 1.013 ms, Emission 12.738 ms, Total 15.077 ms
Execution Time: 123.770 ms
(24 rows) |
Member
|
Looks good. Easier to read TBH, apart from the |
hughrun
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Changes the logic in searching for threads related to a blocked book
What type of Pull Request is this?
Does this PR change settings or dependencies, or break something?
Details of breaking or configuration changes (if any of above checked)
Documentation
Tests