| Aggregate (cost=316.17..316.18 rows=1 width=8) |
| -> Sort (cost=308.84..310.06 rows=489 width=1594) |
| Sort Key: p.updated_at DESC NULLS LAST |
| -> Nested Loop Left Join (cost=17.64..287.00 rows=489 width=1594) |
| Join Filter: (epip.product_id = p.id) |
| Filter: ((COALESCE((sum(tbl_erp_inventory_products.inventory)), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((epop.number - COALESCE(epop.into_inventory, '0'::numeric)))), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((esop.number - COALESCE(esop.outbound, '0'::numeric)))), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((sum(COALESCE(eips.outbound, '0'::numeric))))), '0'::numeric) <> '0'::numeric) OR (COALESCE((sum((sum((epip.number - COALESCE(epip.cancel_number, '0'::numeric)))))), '0'::numeric) <> '0'::numeric)) |
| -> Nested Loop Left Join (cost=17.64..228.16 rows=70 width=140) |
| Join Filter: (eip.product_id = p.id) |
| -> Nested Loop Left Join (cost=0.84..186.60 rows=35 width=108) |
| Join Filter: (tbl_erp_inventory_products.product_id = p.id) |
| -> Nested Loop Left Join (cost=0.84..170.37 rows=5 width=76) |
| Join Filter: (esop.product_id = p.id) |
| -> Nested Loop Left Join (cost=0.56..46.01 rows=1 width=44) |
| Join Filter: (epop.product_id = p.id) |
| -> Index Scan using tbl_products_pkey on tbl_products p (cost=0.28..8.30 rows=1 width=28) |
| Index Cond: (id = 1372) |
| -> GroupAggregate (cost=0.28..37.69 rows=1 width=36) |
| Group Key: epop.product_id |
| -> Nested Loop (cost=0.28..37.67 rows=1 width=12) |
| -> Seq Scan on tbl_erp_purchase_order_products epop (cost=0.00..12.70 rows=3 width=16) |
| Filter: ((product_id = 1372) AND ((number - COALESCE(into_inventory, '0'::numeric)) <> '0'::numeric)) |
| -> Index Scan using tbl_erp_purchase_orders_pkey on tbl_erp_purchase_orders epo (cost=0.28..8.30 rows=1 width=4) |
| Index Cond: (id = epop.erp_purchase_order_id) |
| Filter: ((NOT is_done) AND (status = ANY ('{2,5}'::integer[]))) |
| -> GroupAggregate (cost=0.28..124.29 rows=5 width=36) |
| Group Key: esop.product_id |
| -> Nested Loop (cost=0.28..124.19 rows=5 width=11) |
| -> Seq Scan on tbl_erp_sales_order_products esop (cost=0.00..65.80 rows=8 width=15) |
| Filter: ((product_id = 1372) AND ((number - COALESCE(outbound, '0'::numeric)) <> '0'::numeric)) |
| -> Index Scan using tbl_erp_sales_orders_pkey on tbl_erp_sales_orders eso (cost=0.28..7.30 rows=1 width=4) |
| Index Cond: (id = esop.erp_sales_order_id) |
| Filter: ((NOT is_done) AND (status = ANY ('{2,5}'::integer[]))) |
| -> Materialize (cost=0.00..16.10 rows=7 width=36) |
| -> GroupAggregate (cost=0.00..16.00 rows=7 width=36) |
| Group Key: tbl_erp_inventory_products.product_id |
| -> Seq Scan on tbl_erp_inventory_products (cost=0.00..15.88 rows=7 width=7) |
| Filter: (product_id = 1372) |
| -> Materialize (cost=16.80..40.86 rows=2 width=36) |
| -> GroupAggregate (cost=16.80..40.83 rows=2 width=36) |
| Group Key: eip.product_id |
| -> Append (cost=16.80..40.80 rows=2 width=36) |
| -> GroupAggregate (cost=16.80..38.60 rows=1 width=36) |
| Group Key: eip.product_id |
| -> Nested Loop Left Join (cost=16.80..38.58 rows=1 width=8) |
| Filter: (((eips.erp_sales_outbound_id IS NOT NULL) AND (eso_1.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)) OR ((eips.erp_inventory_transfer_spent_id IS NOT NULL) AND (eit.status = 1))) |
| -> Nested Loop Left Join (cost=16.67..37.21 rows=7 width=42) |
| -> Nested Loop Left Join (cost=16.52..35.47 rows=7 width=40) |
| -> Nested Loop Left Join (cost=16.39..34.25 rows=7 width=38) |
| -> Nested Loop Left Join (cost=16.25..33.03 rows=7 width=36) |
| -> Nested Loop Left Join (cost=16.11..31.59 rows=7 width=34) |
| -> Hash Join (cost=15.96..30.11 rows=7 width=32) |
| Hash Cond: (eips.erp_inventory_product_id = eip.id) |
| -> Seq Scan on tbl_erp_inventory_product_spents eips (cost=0.00..12.65 rows=565 width=32) |
| -> Hash (cost=15.88..15.88 rows=7 width=8) |
| -> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..15.88 rows=7 width=8) |
| Filter: (product_id = 1372) |
| -> Index Scan using tbl_erp_sales_outbounds_pkey on tbl_erp_sales_outbounds eso_1 (cost=0.14..0.21 rows=1 width=6) |
| Index Cond: (id = eips.erp_sales_outbound_id) |
| -> Index Scan using tbl_erp_sales_gifts_pkey on tbl_erp_sales_gifts esg (cost=0.14..0.20 rows=1 width=6) |
| Index Cond: (id = eips.erp_sales_gift_id) |
| -> Index Scan using tbl_erp_inventory_losts_pkey on tbl_erp_inventory_losts eil (cost=0.14..0.17 rows=1 width=6) |
| Index Cond: (id = eips.erp_inventory_lost_id) |
| -> Index Scan using tbl_erp_inventory_builds_pkey on tbl_erp_inventory_builds eib (cost=0.14..0.17 rows=1 width=6) |
| Index Cond: (id = eips.erp_inventory_build_spent_id) |
| -> Index Scan using tbl_erp_inventory_transfers_pkey on tbl_erp_inventory_transfers eit (cost=0.14..0.25 rows=1 width=6) |
| Index Cond: (id = eips.erp_inventory_transfer_spent_id) |
| -> Index Scan using tbl_erp_inventory_disassembles_pkey on tbl_erp_inventory_disassembles eid (cost=0.13..0.17 rows=1 width=6) |
| Index Cond: (id = eips.erp_inventory_disassemble_spent_id) |
| -> GroupAggregate (cost=0.00..2.18 rows=1 width=36) |
| Group Key: eprp.product_id |
| -> Nested Loop (cost=0.00..2.16 rows=1 width=9) |
| Join Filter: (eprp.erp_purchase_return_id = epr.id) |
| -> Seq Scan on tbl_erp_purchase_return_products eprp (cost=0.00..1.07 rows=1 width=13) |
| Filter: (product_id = 1372) |
| -> Seq Scan on tbl_erp_purchase_returns epr (cost=0.00..1.07 rows=1 width=4) |
| Filter: (status = 1) |
| -> Materialize (cost=0.00..55.47 rows=7 width=36) |
| -> GroupAggregate (cost=0.00..55.37 rows=7 width=36) |
| Group Key: epip.product_id |
| -> Append (cost=0.00..55.25 rows=7 width=36) |
| -> GroupAggregate (cost=0.00..19.28 rows=1 width=36) |
| Group Key: epip.product_id |
| -> Nested Loop (cost=0.00..19.26 rows=1 width=12) |
| Join Filter: (epip.erp_purchase_inbound_id = epi.id) |
| -> Seq Scan on tbl_erp_purchase_inbounds epi (cost=0.00..7.72 rows=1 width=4) |
| Filter: (status = 1) |
| -> Seq Scan on tbl_erp_purchase_inbound_products epip (cost=0.00..11.51 rows=2 width=16) |
| Filter: (product_id = 1372) |
| -> GroupAggregate (cost=0.00..2.81 rows=1 width=36) |
| Group Key: epgp.product_id |
| -> Nested Loop (cost=0.00..2.79 rows=1 width=41) |
| Join Filter: (epgp.erp_purchase_gift_id = epg.id) |
| -> Seq Scan on tbl_erp_purchase_gifts epg (cost=0.00..1.27 rows=1 width=4) |
| Filter: (status = 1) |
| -> Seq Scan on tbl_erp_purchase_gift_products epgp (cost=0.00..1.49 rows=2 width=45) |
| Filter: (product_id = 1372) |
| -> GroupAggregate (cost=0.00..2.33 rows=1 width=36) |
| Group Key: eiop.product_id |
| -> Nested Loop (cost=0.00..2.31 rows=1 width=41) |
| Join Filter: (eiop.erp_inventory_overflow_id = eio.id) |
| -> Seq Scan on tbl_erp_inventory_overflow_products eiop (cost=0.00..1.18 rows=1 width=45) |
| Filter: (product_id = 1372) |
| -> Seq Scan on tbl_erp_inventory_overflows eio (cost=0.00..1.12 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=1.15..2.35 rows=1 width=36) |
| Group Key: eibp.product_id |
| -> Hash Join (cost=1.15..2.33 rows=1 width=9) |
| Hash Cond: (eib_1.id = eibp.erp_inventory_build_id) |
| -> Seq Scan on tbl_erp_inventory_builds eib_1 (cost=0.00..1.15 rows=6 width=4) |
| Filter: (status = 1) |
| -> Hash (cost=1.14..1.14 rows=1 width=13) |
| -> Seq Scan on tbl_erp_inventory_build_products eibp (cost=0.00..1.14 rows=1 width=13) |
| Filter: (product_id = 1372) |
| -> GroupAggregate (cost=0.00..2.19 rows=1 width=36) |
| Group Key: eidp.product_id |
| -> Nested Loop (cost=0.00..2.18 rows=1 width=9) |
| Join Filter: (eidp.erp_inventory_disassemble_id = eid_1.id) |
| -> Seq Scan on tbl_erp_inventory_disassemble_products eidp (cost=0.00..1.10 rows=1 width=13) |
| Filter: (product_id = 1372) |
| -> Seq Scan on tbl_erp_inventory_disassembles eid_1 (cost=0.00..1.06 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=0.00..24.03 rows=1 width=36) |
| Group Key: eitp.product_id |
| -> Nested Loop (cost=0.00..24.01 rows=1 width=36) |
| Join Filter: (eitp.erp_inventory_transfer_id = eit_1.id) |
| -> Seq Scan on tbl_erp_inventory_transfer_products eitp (cost=0.00..11.88 rows=1 width=40) |
| Filter: (product_id = 1372) |
| -> Seq Scan on tbl_erp_inventory_transfers eit_1 (cost=0.00..12.12 rows=1 width=4) |
| Filter: (status = 1) |
| -> GroupAggregate (cost=0.00..2.18 rows=1 width=36) |
| Group Key: esrp.product_id |
| -> Nested Loop (cost=0.00..2.16 rows=1 width=9) |
| Join Filter: (esrp.erp_sales_return_id = esr.id) |
| -> Seq Scan on tbl_erp_sales_return_products esrp (cost=0.00..1.07 rows=1 width=13) |
| Filter: (product_id = 1372) |
| -> Seq Scan on tbl_erp_sales_returns esr (cost=0.00..1.07 rows=1 width=4) |
| Filter: (status = 1) |