The cost of getting a good night’s sleep in Scotland has tripled in the last two decades, with nearly £10m spent by the NHS on sleeping pills alone last year.

Despite the increased spending, experts say more people than ever are reporting poor-quality sleep and a growing number of people are chronically sleep-deprived.

While the cost of medication is soaring, the number of prescriptions being handed out has actually fallen across Scotland, with more people looking for a more natural way to catch 40 winks.

In 2001, more than 1.1 million packs of hypnotic drugs were issued by doctors to help people struggling to sleep, but by last year the number had fallen to around 972,000.

Now more people are turning to therapy-based solutions, such as mindfulness and meditation in the quest for the perfect night’s sleep – and for good reason.

READ MORE: Counting the Zs

Not only is sleep important for day-to-day functioning, according to studies by academics the highest earners sleep more on average than those who earn the least, while sleep-deprived people are more likely to develop mental health problems, under-perform at work or have trouble with relationships.

Lisa Artis, a sleep adviser for the UK’s Sleep Council, said: “If you are regularly getting less sleep than you need, your sleep debt increases – and with that you feel grumpier, have less concentration and your memory is impaired.

“Long-term sleep deprivation has a number of health consequences such as obesity, diabetes, high blood pressure, heart attack, stroke and Alzheimer’s.

“Figures show a worrying catch 22 situation for people with depression or those who are obese, because while their conditions can impact on their sleep, sleep deprivation can also make their conditions worse or harder to cope with.

“We also know from a number of studies that those who sleep poorly are more likely to gain weight or struggle to lose it, because poor sleep leads to raised levels of hunger hormone ghrelin and lower levels of leptin, a hormone that’s linked with feelings of fullness.

“And it’s a similar story with depression and anxiety – if you sleep poorly, it makes it coping much harder.

“Sleep regulates your mood and improves your memory, concentration and performance.”

The Sleep Council’s latest "British Bedtime Report" concluded that around a third of people reported having a bad sleep most nights, but for those with depression it was more common – with 53% of people saying they slept poorly. Around 45% of obese people also said they had a bad sleep most nights.

READ MORE: Food is the key to a good night's sleep

The solution to getting the perfect night’s sleep starts in childhood, according to Jane Ansell, chief executive of charity Sleep Scotland.

She founded the charity 22 years ago to offer help to parents of children with additional needs, who are more likely to have problems falling, or staying, asleep.

As a parent of four, including one child who had complex support needs, she said she knew she needed to address the growing sleep deficit within her family.

She said: "This doesn't stop when a child is nine months. When bad sleep habits have become entrenched, it needs an intervention. That isn't magic, there are tried and tested techniques.

"For me, it was very hard getting up in the early hours of the morning and that's the beginning of your day and you have other kids to look after, and a job.

"I had two children and one on the way and I knew we couldn't carry on with this lack of sleep, the deprivation. With a psychology background I was lucky – I did a lot of research and trialled techniques.

"We then started training people how to do interventions in Glasgow and Edinburgh, and the ball has never stopped rolling really."

The charity has now branched out to provide support to parents and teenagers, and has worked with 144 schools to help pupils get a better sleep. Its telephone advice line has taken hundreds of calls in its first 12 months of operation, from families also seeking help.

Ms Ansell added: "Of course social media has an impact too – it is stimulating their mind the whole time and not giving the brain a chance to transition into sleep and it

"It also limits the production of melatonin which is the sleepy hormone."

Although widely accepted that social media and electric gadgets are reasons for not sleeping, one study by an American university showed our theories may be wrong about technology.

Even before smartphones and technology, and in civilisations which don't use electricity, humans still struggled with their 40 winks according to the research carried out in 2015.

Scientists have studied the sleeping patterns of hunter-gatherer tribes in Africa and South America, who do not have electricity or smartphones glued to their sides constantly.

READ MORE: Counting the Zs

Despite being thousands of miles apart, these groups tended to go to sleep a few hours after it got dark, and wake naturally before dawn – managing an average of seven hours' sleep a night.

Jerome Siegel of the University of California, who led the study, said the findings "make it pretty clear that this is the natural pattern [of sleep]".

He said: " Maybe people should be a little bit more relaxed about sleeping. If you sleep seven hours a night, that’s close to what our ancestors were sleeping.”