QUERY PLAN
Group (cost=6.03..6.04 rows=2 width=21)
Group Key: c.object_type, sub.unreadcount
-> Sort (cost=6.03..6.03 rows=2 width=13)
Sort Key: c.object_type, sub.unreadcount
-> Hash Left Join (cost=4.51..6.02 rows=2 width=13)
Hash Cond: ((c.object_type)::text = (sub.object_type)::text)
-> Hash Right Join (cost=1.50..3.00 rows=2 width=5)
Hash Cond: (uc.comment_id = c.id)
Filter: ((uc.remind_user_id = 5495) OR (c.created_by = 5495))
-> Seq Scan on tbl_unread_comments uc (cost=0.00..1.45 rows=19 width=8)
Filter: (remind_user_id = 5495)
-> Hash (cost=1.48..1.48 rows=2 width=13)
-> Seq Scan on tbl_comments c (cost=0.00..1.48 rows=2 width=13)
Filter: (NOT is_system)
-> Hash (cost=2.99..2.99 rows=1 width=13)
-> Subquery Scan on sub (cost=2.96..2.99 rows=1 width=13)
-> GroupAggregate (cost=2.96..2.98 rows=1 width=13)
Group Key: uc_1.object_type
-> Sort (cost=2.96..2.97 rows=1 width=5)
Sort Key: uc_1.object_type
-> Nested Loop (cost=0.00..2.95 rows=1 width=5)
Join Filter: (uc_1.comment_id = c_1.id)
-> Seq Scan on tbl_unread_comments uc_1 (cost=0.00..1.45 rows=1 width=9)
Filter: ((NOT is_read) AND (remind_user_id = 5495))
-> Seq Scan on tbl_comments c_1 (cost=0.00..1.48 rows=2 width=4)
Filter: (NOT is_system)