QUERY PLAN
Limit (cost=9912.13..9912.18 rows=20 width=163)
-> Sort (cost=9912.13..9912.28 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=5653.57..9910.45 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..4171.06 rows=32634 width=9)
Filter: (remind_user_id = 1001)
-> Hash (cost=5650.15..5650.15 rows=273 width=158)
-> Gather (cost=1000.00..5650.15 rows=273 width=158)
Workers Planned: 2
-> Parallel Seq Scan on tbl_comments c (cost=0.00..4622.85 rows=114 width=158)
Filter: (is_system AND ((object_type)::text = '13'::text))