(CNN) -- You know the story of Goldilocks and the three bears, right? Papa Bear's bed was too hard and Mama Bear's bed too soft, but Goldilocks found Baby Bear' bed to be "just right."
That fable could apply to sleep duration in people as they age as well. Just like Baby Bear, older people who sleep "just right" -- getting roughly six to eight hours of quality shut-eye most nights -- appear to delay cognitive decline and keep their brains sharp, according to a study published Wednesday in the journal Brain.
"Our study suggests that there is a middle range, or 'sweet spot,' for total sleep time where cognitive performance was stable over time," said study coauthor Dr. Brendan Lucey in a statement. Lucey is an associate professor of neurology and section head of the Washington University Sleep Medicine Center in St. Louis.
The study monitored the sleep of 100 older adults who were tested for cognitive decline and evidence of early Alzheimer's disease and found that only those who slept six to eight hours retained brain function.
If a person slept fewer than five and a half hours, their cognitive performance suffered, even after controlling for factors like age, sex and Alzheimer's pathology. That applied to people on the other end of the sleep spectrum as well. If they slept more than about seven and a half hours, cognition declined.
"Not only those with short amounts of sleep but also those with long amounts of sleep had more cognitive decline," said coauthor Dr. David Holtzman, scientific director of the Hope Center for Neurological Disorders at Washington University School of Medicine.
"It suggests that sleep quality may be key, as opposed to simply total sleep," he said in a statement.
Aim for continual, quality rest
Adults need to sleep at least seven hours a night, while school-age kids need nine to 12 hours and teens need eight to 10 hours, according to the US Centers for Disease Control and Prevention. Older adults often struggle to get a full seven hours due to chronic conditions and medications that might cause them to wake.
But getting good, restorative sleep is about more than a number. The quality of the sleep you get while your head is on the pillow is also critically important. If you wake frequently due to noises or sleep apnea or to use the bathroom, that's interrupting your sleep cycle -- and depriving the body of the restorative sleep it needs.
The "sweet spot" for sleep is when you can sleep continuously though the four stages of sleep four to six times each night. Since each cycle is roughly 90 minutes long, most people need seven to eight hours of relatively uninterrupted sleep to achieve this goal.
In stages one and two, the body starts to decrease its rhythms. Heartbeat and breathing slow, body temperature drops and eye movements stop. That prepares you for the next stage -- a deep, slow-wave sleep, also known as delta sleep. This is the time the brain repairs the body from the day's wear and tear. During deep sleep, your body is literally restoring itself on a cellular level.
Rapid eye movement sleep, called REM, comes next. This is the stage in which we dream and information and experiences are consolidated and stored in memory. Studies have shown that missing REM sleep may lead to memory deficit and poor cognitive outcomes, as well as heart and other chronic diseases and an early death.
A chronic lack of sleep, therefore, impacts your ability to pay attention, learn new things, be creative, solve problems and make decisions.
Unfortunately, as people age they start to have trouble falling sleeping and staying asleep without interruption, which can dramatically impact deeper sleep and brain function.
A September 2021 study published in the journal JAMA Neurology found that elderly people who slept fewer than six hours a night had more beta amyloid in their brain than those who slept between seven and eight hours. Beta amyloid is a hallmark sign of Alzheimer's disease.
How to improve deep sleep
The good news is that you can train your brain to achieve better sleep, thus giving your body more time to spend in both REM and restorative deep sleep.
Going to bed and waking at the same times each day, including the weekends, is a top tip to get your brain on the road to better sleep, experts say.
Next, set up your sleep environment and establish a relaxing bedtime routine. Yoga, a warm shower, a good but not too exciting book read in soft light -- these are all ways to help your body relax into sleep.
The REM stage of sleep is a lighter level of rest that can more easily be disrupted, so strive for few sounds, little light and cooler temperatures in the bedroom. Remember: The bed should only be used for sleep and sex. Televisions and other blue light-emitting gagets, such as smartphones and laptops, have no place in the bedroom.
Avoid fatty, spicy foods before bed so gastric distress doesn't wake you while you're dreaming.
Alcohol is another no-no. You may think it helps you doze off, but you are more likely to wake in the night as your body begins to process the spirits, thus interrupting those beneficial stages of sleep.
Correction: We got the story of "Goldilocks and the Three Bears" wrong. It was Goldilocks who found Baby Bear's bed to be "just right."
™ & © 2021 Cable News Network, Inc., a WarnerMedia Company. All rights reserved.