| Limit (cost=243.45..243.50 rows=20 width=211) |
| -> Sort (cost=243.45..243.61 rows=62 width=211) |
| Sort Key: c.signed_at DESC, c.created_at DESC |
| -> Group (cost=241.03..241.80 rows=62 width=211) |
| Group Key: c.id |
| -> Sort (cost=241.03..241.18 rows=62 width=203) |
| Sort Key: c.id |
| -> Nested Loop Left Join (cost=183.79..239.18 rows=62 width=203) |
| Join Filter: (sgr.sales_id = client.sales_rep) |
| -> Hash Right Join (cost=183.79..236.61 rows=62 width=207) |
| 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=183.14..183.14 rows=52 width=207) |
| -> Hash Join (cost=110.34..183.14 rows=52 width=207) |
| Hash Cond: (c.client_id = client.id) |
| -> Seq Scan on tbl_sales_contracts c (cost=0.00..68.32 rows=1702 width=203) |
| Filter: (including_tax AND (from_project IS NOT NULL)) |
| -> 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) |
| -> Materialize (cost=0.00..1.64 rows=1 width=4) |
| -> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.64 rows=1 width=4) |
| Filter: (sales_id = 1001) |