Let X and Y be two compact spaces with respective measures μ and ν satisfying the condition μ(X) = ν(Y). Let c be a continuous function on the product space X × Y. The mass transfer problem consists in determining a measure ξ on X × Y whose marginals coincide with μ and ν, and such that the total cost ∫ ∫ c(x,y) dξ(x,y) be minimized. We first show that if the cost function c is decomposable, i.e., can be represented as the sum of two continuous functions defined on X and Y, respectively, then every feasible measure is optimal. Conversely, when X is the support of μ and Y the support of ν and when every feasible measure is optimal, we prove that the cost function is decomposable.