For most living things, especially those of the breathing variety, life without a good supply of oxygen isn't much fun. Goldfish are a rather odd exception.

To get through those inconvenient periods where the environment turns anoxic, fish of the genus Carassius (aka crucian carp and goldfish) have developed a neat way to survive – they make alcohol. Now we know how they do it.

In Biology 101 we learn that oxygen combines with the carbohydrate glucose to form carbon dioxide and water, providing us with energy. The water is relatively useful, while the carbon dioxide is a bi-product we dump out into the environment.

Sometimes our tissues chew through their local oxygen supply, such as during an intense burst of exercise, or the environment temporarily runs low on the stuff.

To cope with the shortage, most animals like us have pathways of enzymes that can still squeeze a bit of energy out of the glucose without oxygen. Unfortunately, this leaves us with a rather nasty substance called lactic acid.

Lactic acid is eventually turned back into glucose in the liver as part of the Cori cycle, but this process also needs oxygen.

In other words, it's only short term solution. If lactic acid continues to build up it will cause lactic acidosis, a condition that lowers the pH of tissues and causes all kinds of problems.

The humble goldfish doesn't have to worry about this. For decades it's been known that this pet-store perennial has a tipsy talent for turning lactic acid into a slightly less dangerous molecule; ethanol.

Unlike lactic acid, the ethanol diffuses quite easily into the water that washes over the fish's gills.*

No other vertebrate has this ability, and so scientists at the Universities of Oslo and Liverpool set out to discover the carp's secret.

It turns out about 8 million years ago, ancestors to the crucian carp and goldfish made copies of the genes responsible for the pyruvate dehydrogenase multienzyme complex.

The original genes retained their original function of preparing a derivative of glucose called pyruvate for entering a metabolic cycle that produces energy.

Meanwhile, the copies of those genes were free to change over time, where they evolved to make an enzyme similar to the one in brewer's yeast that turns the pyruvic acid into acetaldehyde (or ethanal), which is then turned into ethanol.

Usually the fish use the same pathway as other vertebrates, absorbing oxygen through its gills to use in aerobic respiration.

When oxygen is low, the pathway switches over to produce ethanol. While it's not as efficient, it's enough so the carp can easily lay low for months until conditions improve.

"This research emphasises the role of whole genome duplications in the evolution of biological novelty and the adaptation of species to previously inhospitable environments," says lead researcher Cathrine Elisabeth Fagernes from the University of Oslo.

Goldie the goldfish might look right at home turning circles above the stone castle in your tank, but in the wild its ancestors would have had to deal with long winter periods in near frozen waters.

Thankfully it was too cold to drive anywhere.

"During their time in oxygen-free water in ice-covered ponds, which can last for several months in their northern European habitat, blood alcohol concentrations in crucian carp can reach more than 50 milligrams per 100 millilitres, which is above the drink drive limit in these countries," says researcher Michael Berenbrink, an evolutionary physiologist at the University of Liverpool.

"However, this is still a much better situation than filling up with lactic acid, which is the metabolic end product for other vertebrates, including humans, when devoid of oxygen."

It might also explain why goldfish are robust enough to deal with the cold, barely oxygenated tank water in your office aquarium. They're too drunk to care.

Aside from understanding a rather fascinating biological quirk, the research demonstrates an example of exaptation – an evolved shift in a trait's function – through duplication.

Usually, important functions such as those involved in respiration can't simply drop what they're doing to take on a different job. In this case, having a copy was mighty handy.

 This research was published in Scientific Reports.

* ScienceAlert takes no responsibility for people who think this makes the fishbowl a suitable cocktail.