Calcium and magnesium form undesirable salts and soaps with carboxylic acids in crude oil, acting as emulsifiers. Trace amounts of these metals are harmful, causing sedimentation, blockages, and the corrosive production of HCl from NaCl and MgCl2. Vanadium and nickel, concentrated in heavy residues, poison catalysts and require significant reduction via solvent extraction. Desalting is crucial to mitigate these metal-related issues.