Sleep cycles are generally broken up into a series of 90-minute cycles, known as ultradian cycles. These cycles consist of different stages of sleep, including shallow sleep, slow wave sleep, and REM (Rapid Eye Movement) sleep.
Early in the night, these 90-minute cycles tend to be comprised more of shallow sleep and slow wave sleep, with less REM sleep. As the night progresses, each 90-minute cycle starts having more and more REM sleep and less of slow wave sleep.
These different stages of sleep have distinctly different roles in learning and unlearning, and they are responsible for processing different types of information. This includes learning of motor skills, processing of traumatic events, and emotionally challenging or pleasing events.
Regardless of whether your sleep is broken or you wake up in the middle of the night, the more sleep you're getting across the night, the more REM sleep you're going to have.