Sleep is essential for good health, but too much or too little of it can be detrimental, according to a new report.

Researchers from the University of Colorado Boulder recently conducted a study, published in the Journal of the American College of Cardiology, to explore the association between sleep and cardiovascular disease.

To do so, they examined the self-reported sleep habits and medical records of about 461,000 people aged 40 to 69. The participants had never had a heart attack at the beginning of the assessment and were followed for seven years.

After analyzing the results, the scientists found those who slept fewer than six hours nightly were 20% more likely to have a heart attack during the study period, compared to those who got six to nine hours of shuteye. Those who slept more than nine hours nightly were 34% more likely.

"This provides some of the strongest proof yet that sleep duration is a key factor when it comes to heart health, and this holds true for everyone," senior author Celine Vetter said in a statement.

The team also evaluated those who were genetically susceptible to heart disease. Those in that group who slept six to nine hours a night were 18% less likely to have a heart attack.

"It's kind of a hopeful message, that regardless of what your inherited risk for heart attack is, sleeping a healthy amount may cut that risk, just like eating a healthy diet, not smoking and other lifestyle approaches can," lead author Iyas Daghlas said.

The team did not explore why sleeping too little or too much negatively affected heart health. However, they said previous studies explained too much slumber can boost inflammation in the body, which has been linked to cardiovascular disease, while not enough rest can impact the lining of the arteries.

Want to learn more about the findings? Take a look at the full assessment here.