QUERY PLAN
Limit (cost=22130.83..22133.17 rows=20 width=158)
-> Gather Merge (cost=22130.83..26200.45 rows=34880 width=158)
Workers Planned: 2
-> Sort (cost=21130.81..21174.41 rows=17440 width=158)
Sort Key: (CASE WHEN ((c.created_by = 1001) OR uc.is_read) THEN true ELSE false END), c.created_at DESC
-> Merge Left Join (cost=8303.92..19902.15 rows=17440 width=158)
Merge Cond: (c.id = uc.comment_id)
Filter: ((uc.remind_user_id = 1001) OR (c.created_by = 1001))
-> Parallel Index Scan using tbl_comments_pkey on tbl_comments c (cost=0.42..10954.86 rows=75114 width=153)
Filter: is_system
-> Sort (cost=8303.50..8404.17 rows=40269 width=9)
Sort Key: uc.comment_id
-> Seq Scan on tbl_unread_comments uc (cost=0.00..5223.45 rows=40269 width=9)
Filter: (remind_user_id = 1001)