QUERY PLAN
Limit (cost=475.56..477.91 rows=20 width=212)
-> Unique (cost=475.56..513.52 rows=323 width=212)
-> Sort (cost=475.56..476.37 rows=323 width=212)
Sort Key: s.updated_at DESC, s.id, s.sales_order_id, s.product_id, s.parent, s.sn, s.supplier_id, s."order", s.created_by, s.created_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.client_id, s.project_id, s.sales_rep, s.sales_date, 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=458.87..462.10 rows=323 width=212)
Group Key: s.id
-> Hash Left Join (cost=105.97..458.06 rows=323 width=212)
Hash Cond: (s.id = log.sales_order_item_id)
-> Nested Loop (cost=94.01..443.56 rows=323 width=212)
-> Seq Scan on tbl_sales_group_relationships sgr (cost=0.00..1.77 rows=1 width=4)
Filter: ((sales_id = 1001) AND (group_id = 1))
-> Hash Join (cost=94.01..438.56 rows=323 width=216)
Hash Cond: (s.client_id = client.id)
-> Seq Scan on tbl_sales_order_items s (cost=0.00..319.03 rows=9703 width=212)
-> Hash (cost=93.17..93.17 rows=67 width=8)
-> Bitmap Heap Scan on tbl_clients client (cost=4.80..93.17 rows=67 width=8)
Recheck Cond: (sales_rep = 1001)
Filter: (NOT deleted)
-> Bitmap Index Scan on tbl_clients_sales_rep_idx (cost=0.00..4.78 rows=67 width=0)
Index Cond: (sales_rep = 1001)
-> Hash (cost=7.54..7.54 rows=354 width=4)
-> Seq Scan on tbl_sales_order_item_renew_logs log (cost=0.00..7.54 rows=354 width=4)