QUERY PLAN
Sort (cost=937.32..937.34 rows=8 width=484)
Sort Key: p.created_at DESC
-> GroupAggregate (cost=621.75..937.20 rows=8 width=484)
Group Key: p.id
-> Sort (cost=621.75..621.98 rows=94 width=372)
Sort Key: p.id
-> Nested Loop Left Join (cost=8.66..618.67 rows=94 width=372)
-> Nested Loop Left Join (cost=4.33..430.56 rows=8 width=364)
-> Seq Scan on tbl_projects p (cost=0.00..242.68 rows=8 width=356)
Filter: (creator = 5016)
-> Bitmap Heap Scan on tbl_work_logs arrive (cost=4.33..23.48 rows=1 width=12)
Recheck Cond: (project_id = p.id)
Filter: ((NOT is_draft) AND (location_in_id IS NOT NULL) AND (location_out_id IS NOT NULL) AND (client_id IS NOT NULL) AND (scenario_id = 1))
-> Bitmap Index Scan on tbl_work_logs_project_id_idx (cost=0.00..4.33 rows=5 width=0)
Index Cond: (project_id = p.id)
-> Bitmap Heap Scan on tbl_work_logs sl (cost=4.33..23.46 rows=5 width=12)
Recheck Cond: (project_id = p.id)
-> Bitmap Index Scan on tbl_work_logs_project_id_idx (cost=0.00..4.33 rows=5 width=0)
Index Cond: (project_id = p.id)
SubPlan 1
-> Aggregate (cost=39.19..39.20 rows=1 width=32)
-> Seq Scan on tbl_invoices i (cost=0.00..39.19 rows=1 width=6)
Filter: (project_id = p.id)