QUERY PLAN
Limit (cost=20221.35..20223.68 rows=20 width=160)
-> Gather Merge (cost=20221.35..23837.80 rows=30996 width=160)
Workers Planned: 2
-> Sort (cost=19221.32..19260.07 rows=15498 width=160)
Sort Key: (CASE WHEN ((c.created_by = 1001) OR uc.is_read) THEN true ELSE false END), c.created_at DESC
-> Hash Left Join (cost=5276.62..18142.68 rows=15498 width=160)
Hash Cond: (c.id = uc.comment_id)
Filter: ((uc.remind_user_id = 1001) OR (c.created_by = 1001))
-> Parallel Seq Scan on tbl_comments c (cost=0.00..5245.30 rows=67950 width=155)
Filter: is_system
-> Hash (cost=4812.54..4812.54 rows=37127 width=9)
-> Seq Scan on tbl_unread_comments uc (cost=0.00..4812.54 rows=37127 width=9)
Filter: (remind_user_id = 1001)