QUERY PLAN
GroupAggregate (cost=24.35..41.78 rows=1 width=168)
Group Key: contact.id
-> Merge Left Join (cost=24.35..41.75 rows=1 width=140)
Merge Cond: (contact.id = pcp_1.contact_id)
-> Nested Loop (cost=5.34..13.40 rows=1 width=68)
-> GroupAggregate (cost=5.06..5.09 rows=1 width=68)
Group Key: pcp.contact_id
Filter: (sum(pcp.point) IS NOT NULL)
-> Sort (cost=5.06..5.06 rows=1 width=14)
Sort Key: pcp.contact_id
-> Hash Join (cost=0.03..5.05 rows=1 width=14)
Hash Cond: (pcp.project_id = p.id)
-> Seq Scan on tbl_project_contact_points pcp (cost=0.00..4.38 rows=238 width=18)
-> Hash (cost=0.02..0.02 rows=1 width=4)
-> Subquery Scan on p (cost=0.00..0.02 rows=1 width=4)
-> HashAggregate (cost=0.00..0.01 rows=1 width=666)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=4)
One-Time Filter: false
-> Index Only Scan using tbl_contacts_pkey on tbl_contacts contact (cost=0.28..8.30 rows=1 width=4)
Index Cond: (id = pcp.contact_id)
-> GroupAggregate (cost=19.01..25.83 rows=200 width=76)
Group Key: pcp_1.contact_id
-> Sort (cost=19.01..19.56 rows=218 width=18)
Sort Key: pcp_1.contact_id
-> Hash Left Join (cost=5.60..10.55 rows=218 width=18)
Hash Cond: (pcp_1.project_id = p_1.id)
-> HashAggregate (cost=5.57..7.75 rows=218 width=8)
Group Key: pcp_1.contact_id, pcp_1.project_id
-> Seq Scan on tbl_project_contact_points pcp_1 (cost=0.00..4.38 rows=238 width=8)
-> Hash (cost=0.02..0.02 rows=1 width=14)
-> Subquery Scan on p_1 (cost=0.00..0.02 rows=1 width=14)
-> HashAggregate (cost=0.00..0.01 rows=1 width=612)
Group Key: id
-> Result (cost=0.00..0.00 rows=0 width=14)
One-Time Filter: false