We apply the renormalization group optimized perturbation theory (RGOPT) to evaluate the QCD (matter) pressure at the two-loop level considering three flavors of massless quarks in a dense and cold medium. Already at leading order (${\ensuremath{\alpha}}_{s}^{0}$), which builds on the simple one loop (RG resummed) term, our technique provides a nontrivial nonperturbative approximation which is completely renormalization group invariant. At the next-to-leading order the comparison between the RGOPT and the perturbative QCD predictions shows that the former method provides results which are in better agreement with the state-of-the-art higher order perturbative results, which include a contribution of order ${\ensuremath{\alpha}}_{s}^{3}{\mathrm{ln}}^{2}{\ensuremath{\alpha}}_{s}$. At the same time one also observes that the RGOPT predictions are less sensitive to variations of the arbitrary $\overline{\mathrm{MS}}$ renormalization scale than those obtained with perturbative QCD. These results indicate that the RGOPT provides an efficient resummation scheme which may be considered as an alternative to lattice simulations at high baryonic densities.