(Health.com) -- Exercising or having sex just about triples a person's risk of heart attack in the hours immediately afterward, especially if the person does those activities infrequently, according to a new analysis in the Journal of the American Medical Association.

Heart patients shouldn't abstain from sex or forgo exercise based on this finding, however. Although a threefold increase in heart-attack risk sounds scary, the overall likelihood of having a heart attack after working out or making love is still very low -- on the order of 3 in 1,000,000, as opposed to 1 in 1,000,000.

"Definitely, one should not interpret our findings as meaning that physical activity or sexual activity are dangerous or harmful," says one of the study's authors, Issa Dahabreh, M.D., a researcher at Tufts Medical Center's Institute for Clinical Research and Health Policy Studies, in Boston, Massachusetts. "The effect at an individual level is small."

Moreover, the study participants who were more physically active appeared to be less susceptible to a heart attack following intercourse or a workout.

"People who exercise regularly have a much smaller increase in risk, if any," Dr. Dahabreh says.

Numerous studies have suggested that physical activity, including sex, can trigger a heart attack or cardiac arrest, but the magnitude of the risk has been unclear. To arrive at an estimate, Dahabreh and his coauthor reanalyzed data from 14 such studies dating back to the 1980s.

All of the studies used a so-called case-crossover design, in which the participants' activities in the one- to two-hour period leading up to their heart attacks were compared with their usual routines. If physical activity or sex were more common during the pre-heart-attack period than at other times, it would suggest that they triggered the attack.

In the hours after exercising, the researchers found, a person's risk of heart attack increased about 3.5 times, while his or her risk increased about 2.7 times within two hours of having sex. Physical activity also quintupled the risk of sudden death due to cardiac arrest.

However, the risk of heart attack or cardiac death was reduced by 45% and 30%, respectively, for each additional workout the study participants completed in a typical week.

Although the overall (or absolute) risk of heart attack after sex or exercise is "very, very small," Dahabreh says, the findings do suggest that sedentary people who want to get in shape should increase their level of physical activity gradually to avoid undue stress on their hearts. (The American Heart Association makes the same recommendation.)

Geoffrey Tofler, M.D., a professor of preventive cardiology at the University of Sydney Medical School, in Australia, stresses that it is extremely rare for sex or exercise to trigger a heart attack.

"If a healthy 50-year-old person has [a] one-in-a-million chance of having a heart attack in any given hour, tripling the risk will still only make three chances in a million of a heart attack in that hour," says Tofler, a co-author of one of the analyzed studies whowas not involved in the new research.

The analysis was "conducted very thoroughly" and is close to being the last word on the subject, Tofler adds. The findings should reassure heart patients and their partners, who are often anxious about whether it's safe to resume sexual activity after a heart attack or heart-disease diagnosis. "In conjunction with a return to regular physical activity, sexual activity carries a minimal risk," he says.