QUERY PLAN
Nested Loop (cost=5.60..21.69 rows=1 width=150)
-> Group (cost=5.32..13.37 rows=1 width=4)
Group Key: contact.id
-> Nested Loop (cost=5.32..13.37 rows=1 width=4)
-> GroupAggregate (cost=5.03..5.06 rows=1 width=68)
Group Key: pcp.contact_id
Filter: (sum(pcp.point) IS NOT NULL)
-> Sort (cost=5.03..5.04 rows=1 width=9)
Sort Key: pcp.contact_id
-> Hash Join (cost=0.03..5.02 rows=1 width=9)
Hash Cond: (pcp.project_id = p.id)
-> Seq Scan on tbl_project_contact_points pcp (cost=0.00..4.36 rows=236 width=13)
-> 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)
-> Index Scan using tbl_contacts_pkey on tbl_contacts (cost=0.28..8.30 rows=1 width=150)
Index Cond: (id = contact.id)