| Limit (cost=266.63..266.68 rows=20 width=188) |
| -> Sort (cost=266.63..266.76 rows=50 width=188) |
| Sort Key: p.in_out_at DESC NULLS LAST, p.updated_at DESC |
| -> GroupAggregate (cost=263.93..265.30 rows=50 width=188) |
| Group Key: p.id |
| -> Merge Left Join (cost=263.93..264.55 rows=50 width=188) |
| Merge Cond: (p.id = eip_1.product_id) |
| -> Sort (cost=223.93..224.05 rows=50 width=156) |
| Sort Key: p.id |
| -> Hash Right Join (cost=209.68..222.52 rows=50 width=156) |
| Hash Cond: (esosps.erp_inventory_product_id = eip.id) |
| -> Seq Scan on tbl_erp_sales_outbound_spent_products esosps (cost=0.00..10.34 rows=534 width=8) |
| -> Hash (cost=209.08..209.08 rows=48 width=160) |
| -> Hash Right Join (cost=129.46..209.08 rows=48 width=160) |
| Hash Cond: (sc.from_project = epips.project_id) |
| -> Seq Scan on tbl_sales_contracts sc (cost=0.00..68.32 rows=1732 width=4) |
| -> Hash (cost=128.86..128.86 rows=48 width=164) |
| -> Hash Join (cost=123.65..128.86 rows=48 width=164) |
| Hash Cond: (eip.product_id = p.id) |
| -> Hash Right Join (cost=24.91..29.99 rows=48 width=12) |
| Hash Cond: (epips.erp_purchase_inbound_id = epis.id) |
| -> Seq Scan on tbl_erp_purchase_inbound_projects epips (cost=0.00..3.93 rows=193 width=8) |
| -> Hash (cost=24.31..24.31 rows=48 width=12) |
| -> Hash Left Join (cost=9.79..24.31 rows=48 width=12) |
| Hash Cond: (eip.erp_purchase_inbound_id = epis.id) |
| -> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..14.39 rows=48 width=32) |
| Filter: (inventory > '0'::numeric) |
| -> Hash (cost=7.13..7.13 rows=213 width=4) |
| -> Seq Scan on tbl_erp_purchase_inbounds epis (cost=0.00..7.13 rows=213 width=4) |
| -> Hash (cost=72.22..72.22 rows=2122 width=156) |
| -> Seq Scan on tbl_products p (cost=0.00..72.22 rows=2122 width=156) |
| -> GroupAggregate (cost=40.00..40.22 rows=11 width=68) |
| Group Key: eip_1.product_id |
| -> Sort (cost=40.00..40.03 rows=11 width=8) |
| Sort Key: eip_1.product_id |
| -> Nested Loop Left Join (cost=17.23..39.81 rows=11 width=8) |
| -> Hash Left Join (cost=16.95..35.42 rows=11 width=8) |
| Hash Cond: (eips.erp_inventory_disassemble_spent_id = eid.id) |
| Filter: (((eips.erp_sales_outbound_id IS NOT NULL) AND (esos.status = 1)) OR ((eips.erp_sales_gift_id IS NOT NULL) AND (esg.status = 1)) OR ((eips.erp_inventory_lost_id IS NOT NULL) AND (eil.status = 1)) OR ((eips.erp_inventory_build_spent_id IS NOT NULL) AND (eib.status = 1)) OR ((eips.erp_inventory_disassemble_spent_id IS NOT NULL) AND (eid.status = 1))) |
| -> Hash Left Join (cost=15.84..33.16 rows=439 width=36) |
| Hash Cond: (eips.erp_inventory_build_spent_id = eib.id) |
| -> Hash Left Join (cost=14.57..30.72 rows=439 width=34) |
| Hash Cond: (eips.erp_inventory_lost_id = eil.id) |
| -> Hash Left Join (cost=13.37..28.36 rows=439 width=32) |
| Hash Cond: (eips.erp_sales_gift_id = esg.id) |
| -> Hash Left Join (cost=7.46..21.29 rows=439 width=30) |
| Hash Cond: (eips.erp_sales_outbound_id = esos.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eips (cost=0.00..12.65 rows=439 width=28) |
| Filter: ((erp_sales_outbound_id IS NOT NULL) OR (erp_sales_gift_id IS NOT NULL) OR (erp_inventory_lost_id IS NOT NULL) OR (erp_inventory_build_spent_id IS NOT NULL) OR (erp_inventory_disassemble_spent_id IS NOT NULL)) |
| -> Hash (cost=5.54..5.54 rows=154 width=6) |
| -> Seq Scan on tbl_erp_sales_outbounds esos (cost=0.00..5.54 rows=154 width=6) |
| -> Hash (cost=4.29..4.29 rows=129 width=6) |
| -> Seq Scan on tbl_erp_sales_gifts esg (cost=0.00..4.29 rows=129 width=6) |
| -> Hash (cost=1.09..1.09 rows=9 width=6) |
| -> Seq Scan on tbl_erp_inventory_losts eil (cost=0.00..1.09 rows=9 width=6) |
| -> Hash (cost=1.12..1.12 rows=12 width=6) |
| -> Seq Scan on tbl_erp_inventory_builds eib (cost=0.00..1.12 rows=12 width=6) |
| -> Hash (cost=1.05..1.05 rows=5 width=6) |
| -> Seq Scan on tbl_erp_inventory_disassembles eid (cost=0.00..1.05 rows=5 width=6) |
| -> Index Scan using tbl_erp_inventory_products_pkey on tbl_erp_inventory_products eip_1 (cost=0.27..0.40 rows=1 width=8) |
| Index Cond: (eips.erp_inventory_product_id = id) |