QUERY PLAN
Limit (cost=9903.63..9903.68 rows=20 width=163)
-> Sort (cost=9903.63..9903.78 rows=63 width=163)
Sort Key: (CASE WHEN ((c.created_by = 1001) OR uc.is_read) THEN true ELSE false END), c.created_at DESC
-> Hash Right Join (cost=5651.11..9901.95 rows=63 width=163)
Hash Cond: (uc.comment_id = c.id)
Filter: ((uc.remind_user_id = 1001) OR (c.created_by = 1001))
-> Seq Scan on tbl_unread_comments uc (cost=0.00..4165.14 rows=32587 width=9)
Filter: (remind_user_id = 1001)
-> Hash (cost=5647.70..5647.70 rows=273 width=158)
-> Gather (cost=1000.00..5647.70 rows=273 width=158)
Workers Planned: 2
-> Parallel Seq Scan on tbl_comments c (cost=0.00..4620.40 rows=114 width=158)
Filter: (is_system AND ((object_type)::text = '13'::text))