Exercise only prevents dementia if a person gets enough sleep.
A team from University College London studied 9,000 people in England aged 50 and above over the course of a decade and found those who slept between six and eight hours per night fared better in cognitive performance tests along with people who exercised regularly.
However, those in their fifties and sixties who did a lot of exercise but averaged less than six hours of sleep saw a sharp cognitive decline over the 10-year period.
Dr. Mikaela Bloomberg, lead author of the research, said: "Our study suggests that getting sufficient sleep may be required to get the full cognitive benefits of physical activity. It shows how important it is to consider sleep and physical activity together when thinking about cognitive health.
"We were surprised that regular physical activity may not always be sufficient to counter the long-term effects of lack of sleep on cognitive health."