各位大侠,帮我优化一下这段SQL,谢谢了
SELECT DISTINCT mmt.subinventory_code, mmt.inventory_item_id
FROM cux_invgcpor inv, mtl_material_transactions mmt
WHERE 1 = 1
AND mmt.subinventory_code = inv.subinventory_code
AND inv.org_id = mmt.organization_id
AND (mmt.organization_id = 215 OR mmt.organization_id = 3)
SELECTmmt.subinventory_code, mmt.inventory_item_id
FROM cux_invgcpor inv, mtl_material_transactions mmt
WHERE mmt.subinventory_code = inv.subinventory_code
AND inv.org_id = mmt.organization_id
AND mmt.organization_id = 215
AND inv.org_id
= 215
union
SELECTmmt.subinventory_code, mmt.inventory_item_id
FROM cux_invgcpor inv, mtl_material_transactions mmt
WHERE mmt.subinventory_code = inv.subinventory_code
AND inv.org_id = mmt.organization_id
AND mmt.organization_id = 3
AND inv.org_id
= 3
机构上面有索引吗?有的话像上面or展开试验一下。