It's funny you talk about treating the root cause, and take magnesium, instead of addressing the workplace stress factor.
I get what you’re saying, but I think it’s fair to view it as equivalent to drinking a protein shake after a workout. You used the resources in a productive and healthy way, now you need to replenish them.
The magnesium deficiency would probably still exist if you removed the stressful job. Unfortunately switching jobs or careers is not an option in this current job market.
You are absolutely right about that. It is important to reduce stress. Insomnia is only one of the ways excessive stress shows up.