QUERY PLAN
Aggregate (cost=540.05..540.06 rows=1 width=8)
-> GroupAggregate (cost=515.76..540.02 rows=2 width=1057)
Group Key: p.id
-> Nested Loop Left Join (cost=515.76..540.00 rows=2 width=4)
Join Filter: (p.id = tmp5.product_id)
-> Merge Left Join (cost=502.32..521.31 rows=2 width=4)
Merge Cond: (p.id = tmp4.product_id)
-> Nested Loop Left Join (cost=499.74..518.66 rows=2 width=4)
Join Filter: (p.id = tmp3.product_id)
-> Nested Loop (cost=498.11..514.47 rows=2 width=4)
-> Group (cost=497.83..497.84 rows=2 width=4)
Group Key: p_1.id
-> Sort (cost=497.83..497.84 rows=2 width=4)
Sort Key: p_1.id
-> Hash Left Join (cost=347.43..497.82 rows=2 width=4)
Hash Cond: (eip.id = esosps.erp_inventory_product_id)
-> Hash Left Join (cost=334.18..484.53 rows=2 width=8)
Hash Cond: (epips.project_id = sc.from_project)
Filter: ((lower((p_1.name)::text) ~~* '%爱国者%'::text) OR (p_1.pinyin_shortcut ~~* '%爱国者%'::text) OR (lower((pt.name)::text) ~~* '%爱国者%'::text) OR (lower((pb.name)::text) ~~* '%爱国者%'::text) OR (lower((ps.name)::text) ~~* '%爱国者%'::text) OR (lower((pc.name)::text) ~~* '%爱国者%'::text) OR (lower(p_1.description) ~~* '%爱国者%'::text) OR (lower((sc.serial_no)::text) ~~* '%爱国者%'::text))
-> Hash Left Join (cost=194.37..237.63 rows=2121 width=171)
Hash Cond: (p_1.product_component = pc.id)
-> Hash Left Join (cost=188.77..226.31 rows=2121 width=159)
Hash Cond: (p_1.product_serie = ps.id)
-> Hash Left Join (cost=126.86..158.83 rows=2121 width=134)
Hash Cond: (p_1.product_type = pt.id)
-> Hash Left Join (cost=124.44..150.46 rows=2121 width=126)
Hash Cond: (p_1.product_brand = pb.id)
-> Hash Right Join (cost=116.54..136.88 rows=2121 width=122)
Hash Cond: (eip.product_id = p_1.id)
-> Hash Left Join (cost=17.82..36.85 rows=497 width=12)
Hash Cond: (eip.erp_purchase_inbound_id = epis.id)
-> Seq Scan on tbl_erp_inventory_products eip (cost=0.00..12.97 rows=497 width=32)
-> Hash (cost=15.17..15.17 rows=212 width=8)
-> Hash Right Join (cost=10.77..15.17 rows=212 width=8)
Hash Cond: (epips.erp_purchase_inbound_id = epis.id)
-> Seq Scan on tbl_erp_purchase_inbound_projects epips (cost=0.00..3.89 rows=189 width=8)
-> Hash (cost=8.12..8.12 rows=212 width=4)
-> Seq Scan on tbl_erp_purchase_inbounds epis (cost=0.00..8.12 rows=212 width=4)
-> Hash (cost=72.21..72.21 rows=2121 width=114)
-> Seq Scan on tbl_products p_1 (cost=0.00..72.21 rows=2121 width=114)
-> Hash (cost=5.18..5.18 rows=218 width=12)
-> Seq Scan on tbl_product_brands pb (cost=0.00..5.18 rows=218 width=12)
-> Hash (cost=1.63..1.63 rows=63 width=16)
-> Seq Scan on tbl_product_types pt (cost=0.00..1.63 rows=63 width=16)
-> Hash (cost=41.96..41.96 rows=1596 width=33)
-> Seq Scan on tbl_product_series ps (cost=0.00..41.96 rows=1596 width=33)
-> Hash (cost=3.60..3.60 rows=160 width=20)
-> Seq Scan on tbl_product_components pc (cost=0.00..3.60 rows=160 width=20)
-> Hash (cost=118.25..118.25 rows=1725 width=20)
-> Seq Scan on tbl_sales_contracts sc (cost=0.00..118.25 rows=1725 width=20)
-> Hash (cost=8.11..8.11 rows=411 width=8)
-> Seq Scan on tbl_erp_sales_outbound_spent_products esosps (cost=0.00..8.11 rows=411 width=8)
-> Index Only Scan using tbl_products_pkey on tbl_products p (cost=0.28..8.30 rows=1 width=4)
Index Cond: (id = p_1.id)
-> Materialize (cost=1.62..2.85 rows=49 width=4)
-> Subquery Scan on tmp3 (cost=1.62..2.61 rows=49 width=4)
-> HashAggregate (cost=1.62..2.12 rows=49 width=104)
Group Key: p_2.product_id
-> Seq Scan on tbl_erp_inventory_start_products p_2 (cost=0.00..1.50 rows=50 width=4)
-> Sort (cost=2.58..2.61 rows=9 width=4)
Sort Key: tmp4.product_id
-> Subquery Scan on tmp4 (cost=2.26..2.44 rows=9 width=4)
-> HashAggregate (cost=2.26..2.35 rows=9 width=72)
Group Key: p_3.product_id
-> Hash Join (cost=1.06..2.24 rows=9 width=4)
Hash Cond: (p_3.erp_inventory_lost_id = e.id)
-> Seq Scan on tbl_erp_inventory_lost_products p_3 (cost=0.00..1.13 rows=13 width=8)
-> Hash (cost=1.04..1.04 rows=2 width=4)
-> Seq Scan on tbl_erp_inventory_losts e (cost=0.00..1.04 rows=2 width=4)
Filter: (status = ANY ('{2,5}'::integer[]))
-> Materialize (cost=13.44..15.94 rows=100 width=4)
-> Subquery Scan on tmp5 (cost=13.44..15.44 rows=100 width=4)
-> HashAggregate (cost=13.44..14.44 rows=100 width=72)
Group Key: p_4.product_id
-> Hash Join (cost=1.16..13.19 rows=100 width=4)
Hash Cond: (p_4.erp_inventory_overflow_id = e_1.id)
-> Seq Scan on tbl_erp_inventory_overflow_products p_4 (cost=0.00..11.60 rows=160 width=8)
-> Hash (cost=1.10..1.10 rows=5 width=4)
-> Seq Scan on tbl_erp_inventory_overflows e_1 (cost=0.00..1.10 rows=5 width=4)
Filter: (status = ANY ('{2,5}'::integer[]))