Recent literature shows optimal levels of magnesium are important for maintaining adequate levels of testosterone and getting proper amounts of sleep. [19, 20] Most dieticians recommend consuming a daily dosage of 320 mg of magnesium for women and 420 mg of magnesium for men.  Magnesium deficiency is fairly common. According to a recent survey study, about 43% of the US population does not meet the USDA dietary intake of magnesium.  It is more common among people who consume a low-carbohydrate diet. This is partially because the ketogenic diet has a diuretic impact on the body and increases the excretion of ions from the body.
Your doctor may also be able to notify you of any other potential risks a supplement might pose to your health (especially if you're pregnant, have other medical conditions or are planning to have surgery), as well as offer guidance on the best dosage to take. If your doctor isn't comfortable with advising you on supplement use, ask if he or she can refer you to a qualified supplement-savvy health practitioner. But keep in mind that because of a lack of research on side effects, just how a supplement may interact with a medication isn't known.