People who sleep too much or too little are more likely to experience a heart attack, even when other key risk factors are taken into account, a new investigation claims. The sweet spot – six to nine hours – also confers protection on people at high genetic risk for cardiac events.

The results come from an analysis of the self-reported sleep habits of over 460,000 United Kingdom Biobank participants, aged 40 to 69 years. The study subjects had never experienced a heart attack at the outset. Their health data was followed for seven years.

It turned out that the farther people fell outside the ideal sleep range, the more their risk of heart attack increased. For example, individuals who slept five hours a night had a 52% higher chance of heart attack than those who slept seven to eight hours, while those who slept 10 hours nightly doubled their risk.

The six-to-nine-hour sleep range also protected those with a high genetic likelihood for heart attack, cutting their risk by 18%.

The results remained strong even after accounting for 30 other risk factors, including smoking status, physical activity, socioeconomic status and mental health, reported senior author Celine Vetter, Ph.D., University of Colorado at Boulder, and colleagues.

“Just as working out and eating healthy can reduce your risk of heart disease, sleep can too,” Vetter said.

Previous studies have pointed to potential explanations for the results, the authors noted. Sleeping too little has been found to harm the lining of the arteries and lead to weight gain, which can in turn impact heart health. Sleeping too much may boost inflammation in the body, which is associated with cardiovascular disease.

The study was published Sept. 2 in the Journal of the American College of Cardiology.