Data that is to be deduplicated and compressed is received. The data is compressed then deduplicated to generate first compressed then deduplicated data. The data is deduplicated then compressed to generate first deduplicated then compressed data. The first compressed then deduplicated data is stored if the first compressed then deduplicated data is smaller in size than the first deduplicated then compressed data. The first deduplicated then compressed data is stored if the first deduplicated then compressed data is smaller in size than the first compressed then deduplicated data.