| Aggregate (cost=268661.47..268661.48 rows=1 width=8) |
| -> Sort (cost=268661.43..268661.43 rows=3 width=377) |
| Sort Key: (min(CASE WHEN (1 = r.verify_type) THEN CASE WHEN (rvr.status = 0) THEN 1 WHEN (rsvr.status = 0) THEN 2 ELSE 4 END ELSE CASE WHEN ((rvr.status = 0) AND (r.next_verify_user = 5495)) THEN 1 WHEN ((rsvr.status = 0) AND (r.next_stop_verify_user = 5495)) THEN 2 ELSE 4 END END)), r.created_at DESC |
| -> GroupAggregate (cost=184.97..268661.40 rows=3 width=377) |
| Group Key: r.id |
| -> Merge Left Join (cost=184.97..3855.16 rows=11769165 width=30) |
| Merge Cond: (r.id = rsvr.erp_purchase_order_id) |
| -> Merge Left Join (cost=117.15..135.31 rows=48532 width=26) |
| Merge Cond: (r.id = epop.erp_purchase_order_id) |
| -> Sort (cost=93.54..95.34 rows=719 width=26) |
| Sort Key: r.id |
| -> Hash Right Join (cost=35.81..59.43 rows=719 width=26) |
| Hash Cond: (rvr.erp_purchase_order_id = r.id) |
| Filter: ((r.created_by = 5495) OR (rvr.user_id = 5495) OR (r.created_by = ANY ('{5493,5495,5495}'::integer[]))) |
| -> Seq Scan on tbl_erp_purchase_order_verify_rels rvr (cost=0.00..19.70 rows=970 width=12) |
| -> Hash (cost=35.77..35.77 rows=3 width=26) |
| -> Nested Loop Left Join (cost=1.11..35.77 rows=3 width=26) |
| Join Filter: (cs.object_id = c.id) |
| -> Hash Right Join (cost=1.11..2.22 rows=3 width=30) |
| Hash Cond: (c.id = r.purchase_contract_id) |
| -> Seq Scan on tbl_purchase_contracts c (cost=0.00..1.06 rows=6 width=4) |
| -> Hash (cost=1.07..1.07 rows=3 width=30) |
| -> Seq Scan on tbl_erp_purchase_orders r (cost=0.00..1.07 rows=3 width=30) |
| Filter: ((status <> 0) OR ((status = 0) AND (created_by = 5495))) |
| -> Materialize (cost=0.00..33.17 rows=9 width=4) |
| -> Seq Scan on tbl_attachement_relationships cs (cost=0.00..33.12 rows=9 width=4) |
| Filter: (object_type = 108) |
| -> Sort (cost=23.60..24.28 rows=270 width=8) |
| Sort Key: epop.erp_purchase_order_id |
| -> Seq Scan on tbl_erp_purchase_order_products epop (cost=0.00..12.70 rows=270 width=8) |
| -> Sort (cost=67.82..70.25 rows=970 width=8) |
| Sort Key: rsvr.erp_purchase_order_id |
| -> Seq Scan on tbl_erp_purchase_order_stop_verify_rels rsvr (cost=0.00..19.70 rows=970 width=8) |