Four cups of joe a day will keep the doctor away, or so a recent study says. 

Almost 20,000 people participated in a Seguimiento Universidad de Navarra in Pamplona, Spain, study analyzing coffee consumption and its effect on mortality. The study followed the Spanish participants — who were an average of 38 years old when they started the project — for 10 years. In that time, 337 participants died but people who drank four cups of coffee a day had a 64% lower risk of dying than those who never or almost never drank coffee, the study found. 

The link between coffee consumption and a decreased risk of mortality was not as prevalent in younger participants, but those who were at least 45 years old and drank two additional cups of coffee per day had a 30% lower risk of mortality. Researchers took into consideration the participants’ sex, age and adherence to the Mediterranean diet, and collected information about their food intake, lifestyle, health conditions and family history. 

This isn’t the first study to link coffee to longevity. Another U.S.-based study found that four or more cups of coffee a day led to an 18% lower risk of death, and a European study that followed half a million adults 35 years and older for 16.5 years found the more coffee a person drank, the less likely they were to have died by the end of the study. Participants in the European study took a blood test at the beginning of the study, and researchers found people who drank coffee had lower levels of inflammatory factors and sugar. Other studies suggest coffee consumption reduces the risk of dying from a stroke or heart disease.

The researchers of the latter two studies noted that other factors could skew their findings, such as the fact that coffee consumption habits could change over a decade. 

Of course, other studies have found that coffee consumption has its downfalls. One study published in the journal The Lancet said people who drank seven cups of coffee a day were up to 50 times more likely than those who drank two cups or fewer to develop Type 2 diabetes.

Original article on Market Watch.