If you enjoy swimming, snorkeling, surfing or scuba diving in the ocean, at some point you may have wondered how much of what you were floating in originated in the body of a marine animal.

The ocean is home to millions of known species — about 2.2 million, according to a study published in August 2011 in the journal PLOS Biology — which translates into untold numbers of creatures, large and small, from microscopic zooplankton to enormous marine mammals that weigh hundreds of thousands of pounds.

However, the ocean isn't just their home; it's also their toilet. It may be a little daunting to contemplate the vast quantities of waste expelled into seawater every day by the ocean's various creatures, but urine and feces are also nutrient-rich reinvestments that are constantly being consumed and recycled, maintaining the overall health of ocean ecosystems, and playing an important role in supporting food webs.

This is particularly true as far as whales are concerned. [Whale Album: Giants of the Deep]

The biggest contributors

According to Joe Roman, a conservation biologist at the University of Vermont who studies marine mammals and their impact on ocean ecosystems, it should come as no surprise that whales, which are some of the largest animals in the seas, are especially generous contributors to the ocean's chemical soup. However, pinpointing the exact quantities of waste they produce is challenging, Roman told Live Science.

"It's not easy to measure how much a whale excretes in a day," he said. Roman explained that scientists can estimate quantities of whale waste by looking at figures from other large marine animals — such as seals or dolphins, which can be kept in captivity — measuring how much they expel and then scaling that figure up. It's not a direct relationship to what a whale-size bladder or gut can produce, he said, but it provides a general idea.

According to a study published in 2003 in the Canadian Journal of Zoology, the sei whale, a member of the baleen whale family that can measure up to 60 feet (18 meters) long and weigh up to 100,000 lbs. (45,000 kilograms), has an estimated daily urine production of 166 gallons (627 liters). A fin whale, which can grow to be 85 feet (26 m) long and weigh up to 160,000 lbs. (72,575 kg), produces about 257 gallons (974 liters) of urine in one day, the study found.

Roman said that on rare occasions, marine biologists have glimpsed whales peeing at the ocean surface, sending geysers into the air while on their backs.

"But we still haven't figured out how to collect that," he added.

Nutrient plumes

Whale poop, on the other hand, is somewhat easier to spot in the water and is simpler to sample, a feat typically accomplished with plankton nets, Roman said. He explained that whales tend to relieve themselves at the surface before deep feeding dives, releasing massive fecal clouds known as nutrient plumes, which have a distinctive color and "a strong smell."

"It's energetically expensive to dive," Roman told Live Science. "So they shut down a lot of their internal organs when they dive, to become feeding machines. When they come to the surface, that's where they digest and that's where they release urine and feces."

And that generates a highly nutritious bonanza for numerous ocean-dwelling animals, he added, providing them with nitrogen, phosphorous and iron.

Tiny organisms like phytoplankton and algae — thousands of species, Roman said — use the nutrients in whale pee and poop to grow. But it doesn't stop there. Phytoplankton are eaten by larger zooplankton, which are then consumed by fish, which eventually may be eaten by whales. [In Photos: Tracking Humpback Whales in the South Pacific Ocean]

And whales are doing more than just releasing nutrients — they're redistributing them. By feeding in the depths and relieving themselves at the surface, they're connecting surface-dwelling marine animals with nutrients that lie out of reach in the deep ocean.

Waste not, want not

The impressive quantities of waste produced by a whale don't go to waste. (Image credit: GUDKOV ANDREY / Shutterstock)

These infusions of whale waste reinvigorate areas where nutrients have been depleted, Roman said, and are critical for preserving the overall health of marine ecosystems. In a study released in July 2014 in the journal Frontiers in Ecology and the Environment, Roman and his colleagues refer to baleen and sperm whales as "ecosystem engineers," describing the critical role they play in this cycle and reporting that declining whale populations could have a disastrous impact on the innumerable organisms that rely on their nutrient plumes for survival.

"Some literature claims that whales are competing with people for fish, and that if we cull them, there's going to be more fish for us," Roman said. "But our research shows that you can have more whales and more fish, because these whales are releasing nutrients that sustain them. Having lots of marine mammals will make a more productive ocean and a more resilient ocean," he said.

And speaking of fish: Their pee and poop, while not produced in the same prodigious quantities as a whale's (at least, not all at once), also play an important part in the health of marine life and ocean ecosystems.

In turquoise killifish, a diet of poop — and microbes — produced by younger killifish can help to slow the aging process in the older fish. Fish poop also helps eelgrass — a type of marine grass found in oceans worldwide — to reproduce, by distributing its seeds across great distances, according to a study published in 2013 in the journal Marine Ecology. And a chalky substance in fish poop called calcium carbonate could even help to reduce the amount of carbon dioxide in seawater, and could play an important role in Earth's carbon cycle, scientists reported in 2009 in the journal Science.

As for pee, researchers have found that a generous dose of phosphorous-rich fish pee provides corals with a nutritious cocktail that stimulates their growth.

While it may not be possible to calculate just how much pee is produced by all the creatures in the world's oceans, animal waste products are clearly being put to good use. But if you're still worried about how much of it you might be swimming in at the beach this summer, just think about the volume of water that makes up the ocean — about 321 million cubic miles (1.3 billion cubic kilometers), according to the U.S. Geological Survey.

Compared to that, even thousands of gallons of whale pee is just a drop in the bucket.

Editor's Note: This article was first published on June 25, 2016. It was updated on June 21, 2017 with more information about the role of excrement in the oceans.

Original article on Live Science.