We analyze the foundations of the relationship between trade and TFP in the Ricardian model. Under general assumptions about the autarky distributions of industry productivities, trade openness raises TFP. This is due to the selection effect of international competition --- driven by comparative advantages --- which makes "some" high- and "many" low-productivity industries exit the market. We derive a model-based measure of this effect that requires only production and trade data. For a sample of 41 countries, we find that Ricardian selection raised manufacturing TFP by 11% above the autarky level in 2005 (6% in 1985), with a neat positive time trend and large cross-country differences.