It has to be stressful: an obstacle course of giant dams, rushing rapids and hungry predators.

That’s what juvenile salmon can face when they migrate out to the salty sea from the freshwater rivers and streams where they hatched. But it turns out that a very specific kind of pollution might be giving some fish an edge, at least on part of the journey.

According to a new study published Thursday in the journal Science, young salmon exposed to anti-anxiety drugs in the water made it past dams faster. But ecologists are doubtful that it means a survival advantage.

Pharmaceutical pollution is rampant. Nearly 1,000 drugs and their byproducts have been detected in the world’s waterways, including in surprising places like Antarctica. They enter the environment as direct pollution from drug producers, from people flushing unused medications, and from human and animal waste.

Scientists have been studying the effects of these drugs on wildlife for years, but there is still much to learn about how animals respond to the “cocktail of different pharmaceuticals” they’re exposed to, said Michael G. Bertram, a behavioral ecologist at the Swedish University of Agricultural Sciences and a leader of the new study.

There’s a particular interest in psychoactive drugs, like anti-anxiety and antidepressant medications, because they are designed to modify behavior.

Previous studies have found that benzodiazepines, a class of drugs used to treat anxiety and insomnia, can affect migration in Atlantic salmon. They can also decrease stress responses in other fish species.

In short, fish lose their anxiety just as humans do.

Bertram’s team wanted to test whether lab-based findings held up in the wild. They focused on salmon’s smolt phase, when juvenile fish migrate to the ocean.

They exposed salmon smolts to a common anti-anxiety medication, an opioid painkiller, or a mix of both, in doses similar to what the fish might encounter in the wild. There was also a control group that swam only in uncontaminated water. They then equipped the fish with tracking tags and released them into a river in Sweden. The smolts traveled about 17 miles over one to two weeks, navigating a predator-filled reservoir, rapids and two hydropower dams before reaching the Baltic Sea.

“It’s quite a perilous journey,” Bertram said.