In the 19th century, Denmark's main food export was grain to the UK, but it was outcompeted by the United States and Russia and began to switch to pigs and butter from dairy herds. From 1840 to 1870 grain was almost half of Denmark's exports, but by 1900 this had fallen to under 3 per cent. Denmark exported bacon to the United Kingdom from at least 1847, when flitches of bacon were specially prepared for the English market, but had no large-scale production until 1864, when the Second Schleswig War made export of live pigs to Hamburg, where up to then they had been slaughtered and cured, impossible and Denmark was forced to do this locally. However, export to the UK only became significant after Germany, to whom Denmark had been exporting since the Middle Ages, erected trade barriers to (1879), and finally banned (1887), the import of live pigs. The lost German market amounted to almost 300,000 pigs per year and Denmark desperately needed to find a new market. The Danish imports were welcomed in the UK; the growth in population following the Industrial Revolution meant that the country was no longer self-sufficient in food, but there was an increasing demand from a more affluent working class.