In recent years, magnesium has become a bedtime must-have, promising to help you stop waking up at 3 a.m. by preparing your body for deep, peaceful sleep. I've been taking magnesium in the evenings for a while, but lately I've been wondering if I should take melatonin instead.Both are popular sleep supplements, but is magnesium or melatonin better for reducing 3 a.m. wake-ups? "Neither magnesium nor melatonin is a guaranteed solution, but both can be helpful in certain situations," says Dr Shelby Harris, a board-certified clinical psychologist and behavioural sleep medicine specialist.Here I ask Dr Harris and Vanessa Rissetto, a Registered Dietician on the Vitamin Shoppe’s Wellness Council, if either melatonin or magnesium can help you sleep through the night and stop you from waking up at 3 a.m., and what the pros and cons of each are. Here's what they said...Key takeaways: Magnesium vs melatonin at a glanceWhile neither magnesium nor melatonin are guaranteed to prevent middle-of-the-night wake-ups, both are effective at helping you to sleep better. Magnesium can be used to reduce nighttime awakenings if your broken sleep is caused by stress, tension, or a magnesium deficiency. Melatonin is more effective to fall asleep faster, rather than helping you to stay asleep. Always speak to your doctor before taking melatonin, as it isn't suitable for everybody. When taking melatonin, use the lowest effective dose possible, and discuss dosage times with your sleep specialist first. What is magnesium for sleep?According to Rissetto, magnesium is an essential mineral involved in hundred of reactions throughout the body. One such function is promoting calmness as it supports normal muscle relaxation and healthy stress response."I often tell people to think of magnesium as creating the right conditions for good sleep rather than forcing you to fall asleep," shares Rissetto.However, the registered dietician also warns that magnesium "isn’t a magic sleep supplement".