| Aggregate (cost=229.94..229.95 rows=1 width=8) |
| -> Sort (cost=229.92..229.93 rows=1 width=1104) |
| Sort Key: c.signed_at DESC, c.created_at DESC |
| -> Group (cost=229.90..229.91 rows=1 width=1104) |
| Group Key: c.id |
| -> Sort (cost=229.90..229.91 rows=1 width=16) |
| Sort Key: c.id |
| -> Nested Loop Left Join (cost=179.16..229.89 rows=1 width=16) |
| -> Hash Join (cost=179.02..229.03 rows=1 width=20) |
| Hash Cond: (c.client_id = client.id) |
| -> Hash Right Join (cost=68.68..118.60 rows=34 width=20) |
| Hash Cond: (sci2.contract_id = c.id) |
| -> Seq Scan on tbl_sales_contract_invoices sci2 (cost=0.00..44.52 rows=2052 width=4) |
| -> Hash (cost=68.32..68.32 rows=29 width=24) |
| -> Seq Scan on tbl_sales_contracts c (cost=0.00..68.32 rows=29 width=24) |
| Filter: ((from_project IS NULL) AND build_by_project) |
| -> Hash (cost=109.58..109.58 rows=61 width=8) |
| -> Bitmap Heap Scan on tbl_clients client (cost=14.48..109.58 rows=61 width=8) |
| Recheck Cond: (sales_rep = 1001) |
| -> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.80 rows=70 width=0) |
| Index Cond: (sales_rep = 1001) |
| -> Index Only Scan using tbl_sales_group_relationships_pkey on tbl_sales_group_relationships sgr (cost=0.14..0.86 rows=1 width=4) |
| Index Cond: ((sales_id = client.sales_rep) AND (sales_id = 1001)) |