QUERY PLAN
Sort (cost=7.20..7.22 rows=7 width=21)
Sort Key: c.object_type
-> HashAggregate (cost=7.03..7.10 rows=7 width=21)
Group Key: c.object_type, sub.unreadcount
-> Hash Left Join (cost=4.84..6.87 rows=32 width=13)
Hash Cond: ((c.object_type)::text = (sub.object_type)::text)
-> Hash Left Join (cost=1.66..3.56 rows=32 width=5)
Hash Cond: (c.id = uc.comment_id)
Filter: ((uc.remind_user_id = 5493) OR (c.created_by = 5493))
-> Seq Scan on tbl_comments c (cost=0.00..1.48 rows=46 width=13)
Filter: is_system
-> Hash (cost=1.45..1.45 rows=17 width=8)
-> Seq Scan on tbl_unread_comments uc (cost=0.00..1.45 rows=17 width=8)
Filter: (remind_user_id = 5493)
-> Hash (cost=3.16..3.16 rows=1 width=13)
-> Subquery Scan on sub (cost=3.13..3.16 rows=1 width=13)
-> GroupAggregate (cost=3.13..3.15 rows=1 width=13)
Group Key: uc_1.object_type
-> Sort (cost=3.13..3.14 rows=1 width=5)
Sort Key: uc_1.object_type
-> Hash Join (cost=1.46..3.12 rows=1 width=5)
Hash Cond: (c_1.id = uc_1.comment_id)
-> Seq Scan on tbl_comments c_1 (cost=0.00..1.48 rows=46 width=4)
Filter: is_system
-> Hash (cost=1.45..1.45 rows=1 width=9)
-> 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 = 5493))