| Aggregate (cost=111.73..111.74 rows=1 width=8) |
| -> Unique (cost=111.60..111.72 rows=1 width=784) |
| -> Sort (cost=111.60..111.60 rows=1 width=784) |
| Sort Key: s.sales_date DESC, s.created_at DESC, s.id, s.sales_order_id, s.product_id, s.parent, s.sn, s.supplier_id, s."order", s.created_by, s.updated_at, s.pn, s.product_type, s.product_component, s.product_brand, s.product_serie, s.product_misc, s.hardware_from, s.software_from, s.maintenance_from, s.hardware_to, s.software_to, s.maintenance_to, s.new_hardware_deadline, s.new_software_deadline, s.new_maintenance_deadline, s.project_id, s.sales_rep, s.description, s.software_reminded, s.hardware_reminded, s.maintenance_reminded, s.software_advance_reminded, s.hardware_advance_reminded, s.maintenance_advance_reminded, s.is_system, s.amount, s.cost, s.is_renew, s.renew_to_sales_order_item_id, s.number, s.is_merge, s.need_sn, s.erp_sales_outbound_id, s.erp_sales_gift_id |
| -> HashAggregate (cost=111.58..111.59 rows=1 width=784) |
| Group Key: s.id |
| -> Nested Loop (cost=70.38..111.36 rows=88 width=784) |
| -> Nested Loop Left Join (cost=59.12..77.80 rows=10 width=4) |
| -> Index Scan using tbl_clients_pkey on tbl_clients client (cost=35.66..43.69 rows=1 width=8) |
| Index Cond: (id = 1) |
| Filter: ((NOT deleted) AND ((sales_rep = 5493) OR (sales_rep IS NULL) OR (hashed SubPlan 1))) |
| SubPlan 1 |
| -> Seq Scan on tbl_user_visit_clients (cost=0.00..35.50 rows=10 width=4) |
| Filter: (user_id = 5495) |
| -> Bitmap Heap Scan on tbl_sales_group_relationships sgr (cost=23.45..34.01 rows=10 width=4) |
| Recheck Cond: (sales_id = client.sales_rep) |
| -> Bitmap Index Scan on tbl_sales_group_relationships_pkey (cost=0.00..23.45 rows=10 width=0) |
| Index Cond: (sales_id = client.sales_rep) |
| -> Materialize (cost=11.26..32.46 rows=9 width=784) |
| -> Hash Right Join (cost=11.26..32.42 rows=9 width=784) |
| Hash Cond: (log.sales_order_item_id = s.id) |
| -> Seq Scan on tbl_sales_order_item_renew_logs log (cost=0.00..18.80 rows=880 width=4) |
| -> Hash (cost=11.25..11.25 rows=1 width=784) |
| -> Seq Scan on tbl_sales_order_items s (cost=0.00..11.25 rows=1 width=784) |
| Filter: (client_id = 1) |