Let R R be any ring. We prove that all direct products of flat right R R -modules have finite flat dimension if and only if each finitely generated left ideal of R R has finite projective dimension relative to the class of all F \mathcal F -Mittag-Leffler left R R -modules, where F \mathcal F is the class of all flat right R R -modules. In order to prove this theorem, we obtain a general result concerning global relative dimension. Namely, if X \mathcal X is any class of left R R -modules closed under filtrations that contains all projective modules, then R R has finite left global projective dimension relative to X \mathcal X if and only if each left ideal of R R has finite projective dimension relative to X \mathcal X . This result contains, as particular cases, the well-known results concerning the classical left global, weak and Gorenstein global dimensions.