- A number of studies have provided evidence that physical exercise helps reduce age-related decline in cognitive function, and may prevent or delay dementia.
- There is some reason to think older (post-menopausal) women may benefit more than older men.
- While the cognitive benefits of physical exercise for children and younger adults are less clear, there is some evidence that there may be some benefit, although not to the same degree as for older adults.
- Studies indicate that exercise programs involving both aerobic exercise and strength training are of greatest benefit, with exercise sessions lasting at least 30 minutes.
- Apart from age and gender, individual differences also play a part in determining how much value exercise is to an individual.
The effects of exercise on cognitive function in older adults
A number of studies in the past few years have provided evidence that physical exercise can ameliorate the effects of aging on the brain, in terms both of preventing or postponing dementia, and reducing the more normal age-related decline in cognitive function. The reasons for the effect are almost certainly multiple, for example:
- Exercise has clear effects on cardiovascular fitness, and many recent studies have provided converging evidence that there is an association between cardiovascular fitness and mental fitness — "what's good for the heart is good for the brain".
- Exercise helps control blood sugar levels, and a recent study has found that those with impaired glucose tolerance tend to have a smaller hippocampus.
- Exercise may increase the flow of oxygen-rich blood to the brain.
- Exercise may increase self-confidence, and may reduce anxiety and depression.
Interestingly, while exercise benefits both genders, there is some evidence that it may be of greater benefit to women (at older ages). This may be related to estrogen status. There is some evidence that, in females, the benefits of exercise depend on the presence of estrogen. Levels of voluntary physical activity also seem to depend on estrogen status. This may be behind some of the benefit hormone therapy can have on older women's cognitive functioning.
But the undoubted benefits of physical activity for seniors do not imply that exercise has any effect on memory and learning in younger people. That is quite a different question. In seniors, the hope is that exercise will counteract some of the biological wear and tear caused by aging. Does physical fitness matter at younger age levels?
The effects of exercise on cognitive function in children and young adults
Unfortunately, there have been far fewer studies involving young people. However, one study  found that, following a 12 week regimen of jogging for 30 minutes two to three times a week, young adults significantly improved their performance on a number of cognitive tests. The scores fell again if participants stopped their running routine.
In this particular case, it does not seem that level of fitness is the primary cause — otherwise, you'd expect test performance not to be so quickly affected by the cessation of physical activity. The researchers suggested that increased oxygen flow to the brain might have been behind the improvement in mental sharpness. Oxygen intake did rise with the joggers' test scores. Supplemental oxygen administration has been found to significantly improve memory formation in healthy young adults, as well as improving reaction time .
On the other hand, preliminary results from a series of studies undertaken with elementary school children do indicate a strong relationship between academic achievement and fitness scores. One study found that physically fit children identified visual stimuli faster. Brain activation patterns provided evidence that the fit children allocated more cognitive resources towards the task, as well as processing information faster. 
What studies with non-humans tell us
Rodent studies have a big advantage over human studies - many subjects ready to hand, complete control of their environment - and accordingly, it is easier to receive more direct answers. These studies tell us not simply that exercise can be beneficial for learning, but why it might be so.
Studies with mice have made it clear that exercise can:
- increase levels of BDNF (brain-derived neurotrophic factor; BDNF helps support and strengthen the synapses in the brain (the connections between neurons), as well as helping protect and grow new neurons),
- stimulate neurogenesis (the creation of new neurons),
- increase resistance to brain insult, and
- perhaps promote brain plasticity. 
However, while there is no doubt that exercise increases levels of BDNF in the hippocampus, we can’t take it for granted that this is entirely a good thing. Mice bred for 30 generations to be more active (indeed, exercise “addicts”), showed high levels of BDNF and grew more neurons in the hippocampus, and yet performed terribly when attempting to navigate around a maze. Researchers suggested that too much exercise may cause the brain to “max out” in the production of BDNF and neurons, and this may prevent learning. Alternatively, the highly active mice may simply have been too focused on running to concentrate on anything else! 
The point is that at the moment, we don’t know for sure what the significance of the exercise-induced increase in BDNF and neurogenesis is. It may be that high levels of exercise place stress on the hippocampus, damaging or killing neurons. The increased levels of BDNF and neuron production may simply be attempts to counteract the damage done. All that's certain is that exercise provokes a lot of activity in the hippocampus, in particular in that particular region of the hippocampus called the dentate gyrus.
Having said that, let's note that this is the first study to demonstrate a case of neurogenesis that is not associated with learning improvement. In general, the production of new neurons is associated with improvement in learning and memory. It would be unwise, therefore, to take these findings as indicating the reverse. What they do suggest is that we cannot assume that such an association always occurs, and that in the case of exercise, it may well be that you can have too much of a good thing! It does seem clear, from this and other studies, that there is a direct association between amount of exercise and BDNF level.
On the subject of whether you can have too much exercise, it's worth noting that a human study found that, while moderate aerobic exercise for up to an hour improved performance on particular cognitive tasks, too much exercise had a deleterious effect. 
Brain regions affected by exercise
Notwithstanding the (understandable) emphasis placed on the hippocampus, a critical region for learning and memory, human studies have implicated many parts of the brain. Specifically, one study of seniors found that executive functions were particularly improved by exercise - executive functions are primarily located in the prefrontal cortex. Another study of seniors found reduced grey and white matter in the frontal, temporal, and parietal cortexes of those who were less physically fit. In similar vein, another study of seniors found differences in the middle-frontal and superior parietal regions of the brain as a function of aerobic fitness.
Interestingly, in the possibly first study to look at higher cognitive function during exercise (sustained, moderate), it was found that functions dependent on the prefrontal cortex were impaired, but not those requiring little prefrontal activity. 
Exercise and diet
Exercise should not, of course, be considered entirely without reference to diet. The effect of exercise on cardiovascular fitness and blood glucose levels is a counterweight to the effect diet has had in inducing impaired glucose tolerance and cardiovascular problems. A number of rodent studies* have found that a high-fat diet impairs learning and memory. Rodent experiments have also found that exercise can reverse the decrease in BDNF levels in the hippocampus resulting from a high-fat diet, and prevent the deficit in spatial learning induced by such a diet. 
The question might therefore arise, if the diet has been healthy, is exercise beneficial? Interestingly, a very recent study involving older beagles found that both a diet enriched with antioxidants and a stimulating environment were helpful in preventing or reducing age-related cognitive decline. That is, each were good, but both was best. This doesn't directly answer the question, of course, but it does seem likely that both diet and exercise are important factors in physical and mental health.
Physical exercise and mental exercise
The beagle study used what is termed an "enriched" environment — typically this involves opportunities for social interaction and mental stimulation, as well as physical activity. A mouse study endeavored to separate the components of such an enriched environment, in order to see whether all were necessary to achieve the observed increased neuron production in the dentate gyrus. Interestingly, they found that voluntary wheel running was in itself sufficient to achieve the level of neurogenesis achieved in typical enrichment conditions. 
This is intriguing, but as much as anything else it points to the limitations of rodent studies as models for human behavior. A number of human studies, again, mainly with older adults, point to the value of mental stimulation in protecting against cognitive decline. Interestingly, one such study found ballroom dancing was apparently of (surprising) value in protecting against age-related cognitive decline — it was suggested that there was an intellectual component to it lacking in other physical activities. But perhaps, if I may speculate, we should consider more seriously that activities that combine intellectual and physical (and perhaps social) attributes might be best of all.
It does seem clear that, while both mental stimulation and physical exercise might both help cognitive function, they do so in quite different ways, for different reasons.
An analysis of 18 studies  on the effects of exercise on cognitive function in older adults concluded that:
- exercise programs involving both aerobic exercise and strength training produced better results on cognitive abilities than either one alone
- more than 30 minutes of exercise per session produce the greatest benefit
Caveat: Not everyone benefits equally from exercise
It does seem clear that older adults benefit more from exercise than younger people, as far as cognitive function is concerned. It also seems that older women, especially those on hormone-replacement therapy, receive greater cognitive benefits from exercise than men.
Generalisations aside, it is as well to remember the findings of a very recent study showing that, while most people benefit (physically) from exercise, the degree of benefit is hugely variable between individuals, and some people don’t benefit at all! 
* In one study, young adult male mice were divided into four groups by diet: normal (control) diet, high-saturated-fat diet, high-sugar diet, and diet high in saturated fats and sugar. They were kept on the diet for four months, during which mice on the high-fat and high-fat-&-sugar diets gained significantly more weight than those on the control and high sugar diets. At the end of that time, the mice were tested on a maze task. Mice on the high-fat and high-fat-&-sugar diets performed worse than the other mice. The mice were then exposed to a neurotoxin called kainic acid, which is known to damage nerve cells in the hippocampus. Mice on the high-fat and high-fat-&-sugar diets were significantly more impaired by the neurotoxin.
In another mouse study, obese mice were fed a diet containing about 10% fat for seven months, while control mice were fed standard lab chow containing only 5% fat. On testing, it was found that the obese mice took significantly more trials than the normal-weight mice to both acquire and retain a memory of a foot shock. They also required significantly more trials than control mice to learn to press a lever for milk reinforcement.
A rat study explored whether a diet high in cholesterol and hydrogenated fats affected working memory in middle-aged rats (corresponding to 60 and older for humans). The high-fat, high-cholesterol diet produced significantly higher plasma triglycerides, total cholesterol, high density lipoprotein cholesterol, and low density lipoprotein cholesterol compared with controls. Weight increase and food consumption were similar between the groups. Animals on the high-fat regimen made more errors than animals fed the control diet, especially during the trial that placed the highest demand on their working memory.
Another rat study found that a diet high in fats and carbohydrates worsened cognitive deficits in rats exposed to repeated brief periods of low oxygen during sleep (as experienced by people with sleep apnea). Press release
- Harada, T., Okagawa, S., & Kubota, K. (2004). Jogging improved performance of a behavioral branching task: implications for prefrontal activation. Neuroscience Research, 49(3), 325–337.
- Scholey, A.B., Moss, M.C., Neave, N. & Wesnes, K. 1999. Cognitive Performance, Hyperoxia, and Heart Rate Following Oxygen Administration in Healthy Young Adults. Physiology & Behavior, 67 (5), 783-789.
- Hillman, C. & Buck, S. 2004. Physical Fitness and Cognitive Function in Healthy Preadolescent Children. Presented at the annual meeting of the Society for Psychophysiological Research in Santa Fe, N.M., Oct. 20-24. Press release
- Cotman, C.W. & Berchtold, N.C. 2002. Exercise: a behavioral intervention to enhance brain health and plasticity. Trends in Neurosciences, 25 (6), 295-301.
- Rhodes, J.S., van Praag, H., Jeffrey, S., Girard, I., Mitchell, G.S., Garland, T.Jr. & Gage, F.H. 2003. Exercise increases hippocampal neurogenesis to high levels but does not improve spatial learning in mice bred for increased voluntary wheel running. Behavioral Neuroscience, 117(5), 1006-1016.
- Tomporowski,P.D. 2003. Effects of acute bouts of exercise on cognition. Acta Psychol (Amst), 112, 297-324.
- Dietrich, A. & Sparling, P.B. 2004. Endurance exercise selectively impairs prefrontal-dependent cognition. Brain and Cognition, 55 (3), 516-524.
- Molteni, R., Wu, A., Vaynman, S., Ying, Z., Barnard, R.J. & Gómez-Pinilla, F. 2004. Exercise reverses the harmful effects of consumption of a high-fat diet on synaptic and behavioral plasticity associated to the action of brain-derived neurotrophic factor. Neuroscience, 123 (2), 429-440.
- van Praag, H., Kempermann, G. & Gage, F.H. 1999. Running increases cell proliferation and neurogenesis in the adult mouse dentate gyrus. Nature Neuroscience, 2 (3), 266-70.
- Colcombe, S. & Kramer, A.F. 2003. Fitness effects on the cognitive function of older adults: A meta-analytic study. Psychological Science, 14, 125-130.
- Bouchard, C. 2004. Reported at the Australian Health and Medical Research Congress in Sydney, Australia. http://www.newscientist.com/article/dn6735-some-people-are-immune-to-exe...