This drill is called the side lying windmill. It is one of the best drills I've used so far to not only help improve people's thoracic mobility, but as a result help people create better movement patterns (and in some cases it has a by-product of alleviating pain, although relieving pain is not my job nor intention) for other areas such as the shoulders and hips.
Since the thoracic spine is the area of your spine that is meant to be more mobile, when it gets stiff or immobile, the areas such as the lumbar spine (low back area) and cervical spine (neck area) tend to create mobility they should not have. This generally leads to problems in the low back/ hips area and the upper back/neck and shoulders area.
Try giving this mobility drill a shot next time you're getting ready to workout, or after a long day of sitting at your desk. Your body will thank you for it.