Before you start self-medicating -- "participants had a mean age of 67.2±8.9" and this is a study focusing on people with mild cognitive impairment.
You should see a physician before attempting to treat your poor sleep with vitamin D or melatonin.
"Self-medicating" with a standard multivitamin is harmless at worst, and so is additional vitamin D supplementation if it's not in the extreme over a long period of time. It has a nonzero chance of helping, and it's a cheap and easy thing to throw into one's routine.
This guy is another murderer. You don't need to see a doctor to take vitamin D or melatonin, although you do need to empirically optimize the dose for what is both optimal and safe.