Aggregate (cost=52.00..61.64 rows=32 width=241) -> Group (cost=52.00..57.62 rows=321 width=241) -> Sort (cost=52.00..52.80 rows=321 width=241) Sort Key: m.group_code, m.sku, m.brn_code, m.stktype_code, ss.supplier_price_curr_cost, sk.sku_price_curr_cost -> Merge Join (cost=36.38..38.62 rows=321 width=241) Merge Cond: (("outer".group_cde = "inner".group_cde) AND ("outer".brn_code = "inner".brn_code)) Join Filter: (("outer".price_tmpl_hdr_cde = "inner".price_tmpl_hdr_cde) AND ("outer".price_tmpl_hdr_reg = "inner".price_tmpl_hdr_reg)) -> Nested Loop (cost=0.00..1407212.08 rows=63 width=179) Join Filter: (("inner".sku_mst_cde = "outer".sku) AND ("inner".group_cde = "outer".group_code)) -> Merge Join (cost=0.00..1405644.89 rows=315 width=135) Merge Cond: ("outer".group_code = "inner".group_code) Join Filter: ("outer".sku = "inner".sku) -> Nested Loop (cost=0.00..4826563.70 rows=8694 width=108) -> Index Scan using master_fpp_values_idx2 on master_fpp_values m (cost=0.00..3766902.34 rows=215650 width=54) Filter: (fpp_code = '200307'::text) -> Index Scan using pk_supplier_price on supplier_price ss (cost=0.00..4.90 rows=1 width=54) Index Cond: ((ss.group_cde = "outer".group_code) AND (ss.sku_mst_cde = "outer".sku) AND (ss.supplier_cde = "outer".supplier_code)) -> Index Scan using master_sku_descr_idx3 on master_sku_descr s (cost=0.00..2535.04 rows=10758 width=27) Filter: (control_code = '0'::text) -> Index Scan using idx_sku_price on sku_price sk (cost=0.00..4.96 rows=1 width=44) Index Cond: ((sk.group_cde = "outer".group_cde) AND (sk.sku_mst_cde = "outer".sku_mst_cde) AND (sk.price_tmpl_hdr_cde = "outer".price_tmpl_hdr_cde) AND (sk.price_tmpl_hdr_reg = "outer".price_tmpl_hdr_reg)) -> Sort (cost=36.38..36.87 rows=198 width=62) Sort Key: p.group_cde, p.branch_cde -> Hash Join (cost=18.46..28.82 rows=198 width=62) Hash Cond: ("outer".brn_code = "inner".branch_cde) -> Merge Join (cost=13.94..20.34 rows=198 width=33) Merge Cond: ("outer".country_code = "inner".from_ctry) -> Index Scan using master_branch_descr_idx4 on master_branch_descr b (cost=0.00..33.12 rows=198 width=15) -> Sort (cost=13.94..13.95 rows=4 width=18) Sort Key: f.from_ctry -> Index Scan using forex_idx1 on forex f (cost=0.00..13.90 rows=4 width=18) Index Cond: ((to_ctry = 'ZAF'::text) AND (fpp_code = '200307'::text)) -> Hash (cost=4.02..4.02 rows=202 width=29) -> Seq Scan on price_tmpl_det p (cost=0.00..4.02 rows=202 width=29) (34 rows)