QUERY PLAN
Group (cost=6.02..6.03 rows=1 width=21)
Group Key: c.object_type, (count(*))
-> Sort (cost=6.02..6.02 rows=1 width=13)
Sort Key: c.object_type, (count(*))
-> Nested Loop Left Join (cost=4.47..6.01 rows=1 width=13)
Join Filter: ((uc_1.object_type)::text = (c.object_type)::text)
-> Hash Right Join (cost=1.50..3.00 rows=1 width=5)
Hash Cond: (uc.comment_id = c.id)
Filter: ((uc.remind_user_id = 5493) OR (c.created_by = 5493))
-> Seq Scan on tbl_unread_comments uc (cost=0.00..1.45 rows=17 width=8)
Filter: (remind_user_id = 5493)
-> 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)
-> 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 = 5493))
-> Seq Scan on tbl_comments c_1 (cost=0.00..1.48 rows=2 width=4)
Filter: (NOT is_system)