But the age at which a person is obese seems to be a key factor, the findings show, with an apparent tripling in risk for people in their 30s.

Estimates suggest that almost 66 million people around the globe will have dementia by 2030, with the numbers predicted to top 115 million by 2050.

There is growing evidence that obesity is linked to dementia, but the research indicates that risk may be heightened or lowered, depending on age. And as yet, no study has looked at the age related effect of obesity on dementia risk across the whole age range in the population of one country.

So the researchers decided to do this, using anonymised data from hospital records for the whole of England for the period 1999-2011. Data in which obesity had been recorded were then searched for any subsequent care for, or death from, dementia.

During the study period, 451 232 of those admitted to hospital in England were diagnosed with obesity, 43% of whom were men.

The analysis revealed an incremental decrease in overall risk of hospital admission for dementia the older a person was when a diagnosis of obesity was first recorded, irrespective of gender.

For those aged 30-39, the relative risk of developing dementia was 3.5 times higher than in those of the same age who were not obese. For those in their 40s, the equivalent heightened risk fell to 70% more; for those in their 50s to 50% more; and for those in their 60s to 40% more.

People in their 70s with obesity were neither at heightened or lowered risk of developing dementia, while those in their 80s were 22% less likely to develop the disease, the findings indicated.

There were some age differences between the risk of developing vascular dementia or Alzheimer's disease, with those in their 30s at greater risk of both. A diagnosis of obesity in the 40s through to the 60s was associated with an increased risk of vascular dementia, while the risk of Alzheimer's disease was lower in those diagnosed with obesity from their 60s onwards.

This is an observational study, so no definitive conclusions can be drawn about cause and effect. But the findings confirm smaller published studies from elsewhere which report an increased risk of dementia in young people who are obese, but a reduced risk in older obese people, say the researchers.

They venture that a possible explanation for the particularly high risk found in early to mid-life may lie in the fact that heavier weight is associated with diabetes and cardiovascular risk factors, which are themselves linked to a heightened risk of dementia.

And it would seem that if people can stave off significant weight gain until at least their 60s, or survive long enough with obesity, they may have a lower risk of developing dementia, they suggest.

"While obesity at a younger age is associated with an increased risk of future dementia, obesity in people who have lived to about 60-80 years of age seems to be associated with a reduced risk," they conclude.

###