| Aggregate (cost=168.16..168.17 rows=1 width=8) |
| -> Sort (cost=167.18..167.34 rows=65 width=623) |
| Sort Key: c.signed_at DESC, c.created_at DESC |
| -> HashAggregate (cost=164.57..165.22 rows=65 width=623) |
| Group Key: c.id |
| -> Hash Left Join (cost=85.65..164.41 rows=65 width=16) |
| Hash Cond: (client.sales_rep = sgr.sales_id) |
| -> Nested Loop Left Join (cost=83.51..161.68 rows=65 width=20) |
| -> Nested Loop (cost=83.23..130.56 rows=65 width=20) |
| -> Index Only Scan using tbl_suppliers_pkey on tbl_suppliers supplier (cost=0.28..8.29 rows=1 width=4) |
| Index Cond: (id = 138) |
| -> Hash Right Join (cost=82.95..121.62 rows=65 width=24) |
| Hash Cond: (pcr.contract_id = c.id) |
| -> Seq Scan on tbl_purchase_client_rels pcr (cost=0.00..33.11 rows=2111 width=8) |
| -> Hash (cost=82.14..82.14 rows=65 width=20) |
| -> Seq Scan on tbl_purchase_contracts c (cost=0.00..82.14 rows=65 width=20) |
| Filter: ((cost_type = ANY ('{1,2}'::integer[])) AND (supplier_id = 138)) |
| -> Index Scan using tbl_clients_pkey on tbl_clients client (cost=0.28..0.48 rows=1 width=8) |
| Index Cond: (pcr.client_id = id) |
| -> Hash (cost=1.51..1.51 rows=51 width=4) |
| -> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.51 rows=51 width=4) |