QUERY PLAN
Aggregate (cost=14616.53..14616.54 rows=1 width=8)
-> Sort (cost=14608.24..14609.62 rows=553 width=248)
Sort Key: (CASE WHEN ((c.created_by = 5064) OR uc.is_read) THEN true ELSE false END), c.created_at DESC
-> Hash Right Join (cost=10225.89..14583.04 rows=553 width=248)
Hash Cond: (uc.comment_id = c.id)
Filter: ((uc.remind_user_id = 5064) OR (c.created_by = 5064))
-> Gather (cost=1000.00..4551.40 rows=523 width=9)
Workers Planned: 1
-> Parallel Seq Scan on tbl_unread_comments uc (cost=0.00..3499.10 rows=308 width=9)
Filter: (remind_user_id = 5064)
-> Hash (cost=6390.86..6390.86 rows=163042 width=16)
-> Seq Scan on tbl_comments c (cost=0.00..6390.86 rows=163042 width=16)
Filter: is_system