Anyone who's had a urinary tract infection knows how annoying they can be. If you make sure to always pee after sex, here's another prevention method you might want to add to your arsenal: exercise. New research suggests that regular physical activity, even at low levels, may be protective against bacterial infections—and the findings were especially promising when it came to UTIs.

The study, published in the journal Medicine and Science in Sports and Exercise, followed nearly 19,000 people in Denmark for one year. Previously, the participants had been asked to rank their leisure-time physical activity on a scale of 1 (“regular hard physical training and competitive sports several times per week”) to 4 (“reading, watching television, or other sedentary behaviors”). This divided them into three physical-activity groups—vigorous, moderate, and low—as well as a sedentary group. (Anyone who was sedentary because of a history of cancer, diabetes, heart disease, or lung disease was not included in the study.)

Over the course of the year, researchers from Aalborg University in Denmark used national pharmacy data to see which people filled prescriptions for antibiotics. About 22% of men and 34% of women were given at least one antibiotic—indicating that they’d been diagnosed with a bacterial infection—in that time.

RELATED: 7 Things Every Woman Should Know About UTIs

When they controlled for factors such as age, body mass index, smoking status, and alcohol consumption, the researchers found that people in the low physical-activity group were 10% less likely to have had an infection than those in the sedentary group. Low physical activity was defined as strolling, riding a bicycle, light gardening, or other light physical activity for at least 4 hours a week.

The link was especially strong when they looked at people who’d had drugs prescribed specifically for UTIs. Volunteers in the low- and moderate-activity groups had a 21% and 32% lower risk, respectively, compared to sedentary people.

This could be an important finding, since more than half of women (and yes, some men) will get a UTI in their lifetime. In the United States, the illness—characterized by an intense need to urinate and a burning sensation while doing so—results in more than 8 million doctor’s visits each year.

The researchers also looked specifically at bacterial respiratory tract infections, such as sinusitis and pneumonia. Previous studies have suggested that exercise can protect against these types of illnesses, but no significant association was found in this analysis.

RELATED: Is Wearing Workout Leggings All Day Bad for My Vagina?

When the researchers applied their analysis to just the men in the study, they found that results were not statistically significant—possibly because the strongest association came from UTIs, of which men had far fewer. However, the findings did suggest a “J-shaped tendency,” the authors wrote, in which low and moderate levels of physical activity were associated with a decrease in antibiotic use (compared to sedentary behavior), but vigorous activity was associated with an increase.

These findings are similar to those of previous studies, done on athletes, that suggest that exhaustive, high-intensity exercise may actually lower immunity and increase the risk of viral infections. (In other words, it is possible to get too much of a good thing.)

The results for women didn’t show an increased risk for vigorous exercisers: All levels of physical activity appeared to lower the risk of infection compared to sedentary behavior, although adjusted results were only significant for the low-activity group.

RELATED: The Weird Way Exercise Could Help Your Immune System

Of course, the study couldn’t definitively prove that participants had these infections, based on antibiotic prescriptions alone—or that exercise habits played a direct role in their susceptibility for them. And the authors admit that one question about leisure-time exercise certainly doesn’t tell the whole story.

But their findings do show a “significant protective effect” of low physical activity on the risk of suspected bacterial infection, they wrote, and of low and moderate activity on the risk of UTIs specifically. “These results indicate that practitioners should be aware of physical activity as a potential preventive factor for bacterial infections in the work of disease prevention and health promotion,” they concluded.