"Supplementation of 500 mg of Mg has been associated with significant improvement in the insomnia severity index, sleep time, sleep efficiency, sleep onset latency, serum cortisol concentration, serum renin, and melatonin"
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5637834/
More: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3703169/ https://www.ncbi.nlm.nih.gov/pubmed/23853635 https://www.ncbi.nlm.nih.gov/pubmed/8232845