At least since Shakespeare’s day, people have recognized that alcohol has curious and often contradictory effects on sleep. One character in Macbeth remarks that while alcohol can promote sleep, too much of it leads to restless nights. Ask a sleep scientist today whether booze helps or harms sleep, and you’ll get a similar reply. “What alcohol gives, it takes away,” says Timothy Roehrs, director of research in the Sleep Disorders and Research Center at Detroit’s Henry Ford Health System.

Roehrs has been studying alcohol’s effects on sleep since the 1980s and says drinking has a “paradoxical effect” on slumber. While there’s no doubt heavy drinking is a recipe for tossing and turning, there’s a case to be made that judicious amounts of alcohol can both promote and bolster sleep.

For people who drink sparingly, a little alcohol before bed can promote restful sleep at least in the short term. “After you consume alcohol, it actually enhances sleep,” says Roehrs. “So you fall asleep faster, and for at least three to five hours, your sleep might be deeper.”

A 2016 study from the University of Missouri found that alcohol may promote sleep by increasing the buildup of adenosine — a brain chemical that accumulates throughout the day as the body burns energy. Alcohol is such a potent sleep inducer that it’s actually included in some popular sleep medications. Some varieties of Vicks ZzzQuil, for example, contain 10% alcohol by volume.

There’s a case to be made that judicious amounts of alcohol can both promote and bolster sleep.”

Not only does alcohol make us sleepy, it also changes the architecture of our sleep. While these changes to sleep rhythms are measurable proof that alcohol affects sleep, Roehr’s says these shifts, when subtle, aren’t always indicative of a poor night’s rest.

Our sleep tends to occur in predictable cycles that repeat every few hours Roehrs says. We enter first into non-REM sleep, which includes a slow-wave sleep stage that’s thought to be most restorative, he says. After that, our sleep lightens and we experience stages of REM sleep, which are often when we dream. During healthy sleep, these non-REM/REM cycles repeat throughout the night, with time spent in REM sleep increasing as the night wears on. But when a person drinks alcohol, these shifts are exaggerated; non-REM sleep dominates the first half of the night, while REM sleep increases more than usual during the back half. But some research has found that alcohol-related shifts to a person’s sleep architecture tend to fade within a week for those who consume modest amounts — meaning booze neither helps nor hurts their sleep.

On the other hand, Roehrs’ research also shows that these benefits can be short-lived; after six straight days of moderate drinking — roughly one to two drinks a night — a person’s alcohol tolerance increases and the associated sleep improvements can wear off. At this point, people may “self-administer” greater and greater amounts of alcohol in order to fall asleep, which over time could increase their risks for alcohol abuse, he says.

So, is there a “just-right” amount that can usher in the Sand Man without chasing him away a few hours later?

It appears so. Assuming you’re drinking in moderation and you’re not doing so every night, alcohol can both bring on sleep and facilitate deep sleep without significantly disrupting slumber later in the night, Roehrs says. One 2006 study from Germany found that a drink or two had no impact on sleep for healthy adults. Other research shows insomniacs — albeit ones who don’t drink too often — may particularly benefit from a nightcap. For these troubled sleepers, alcohol appears to increase the amount of deep, slow-wave sleep they experience late in the night, which is not the case for healthy sleepers.

Not only does alcohol make us sleepy, it also changes the architecture of our sleep.”

While the occasional drink may provide some sleep benefits, heavy drinking doesn’t do your sleep any favors. “When we put people in bed with blood concentrations above a certain threshold, they will inevitably be wakeful during the last four hours of the night,” Roehrs says.

Heavy drinking’s negative effect on sleep is so predictable that experts say you can practically set a clock by it. When a patient mentions waking up at the same time each night — typically around two or three in the morning — the culprit is almost always too much alcohol, says Dr. Damien Stevens, director of fellowship training in sleep medicine at the University of Kansas Medical Center. “Depending on a person’s metabolism, the alcohol is usually gone after three or four hours, and that’s when you’re going to get arousals,” he says.

All this is supported by a 2017 study that found alcohol significantly and predictably reduces a person’s sleep quality: Each drink a person in the study consumed led to a small but measurable reduction in his or her sleep quality. “We found that participants report worse sleep quality after the days when they drink alcohol,” says study author David Lydon-Staley, a post-doctoral researcher at the University of Pennsylvania.

It’s not entirely clear why heavy drinking impacts sleep quality. Some research suggests the metabolization of alcohol increases sympathetic nervous system activity — speeding a person’s heart rate and stimulating mental activity — in ways that disrupt sleep. The more you drink, the more this sympathetic nervous system activity increases and the more restive you become once the alcohol in your system has burned off.

What if you drink a little alcohol every single night? Right now there’s a gap in the literature when it comes to the long-term effects of low or moderate alcohol consumption. Roehrs says most sleep-and-alcohol studies are focused on people who either have problems sleeping or who have been given relatively heavy doses of booze. In many cultures — including some of the healthiest on the planet — it’s typical to drink a little alcohol (usually wine) with meals. There’s not much evidence that this kind of drinking messes with sleep. In fact, some studies have linked low or moderate drinking with reduced rates of sleep apnea. And if you stick to one or two drinks, research suggests your body will clear that away within three to six hours. That means if you’re drinking early in the evening, the alcohol may have left your system by the time you hit the sack.

Experts also agree that healthy sleep is built on routine. If you’re accustomed to drinking every night, switching up your habits may mess with your sleep. While heavy drinking is consistently linked with poor sleep and its side effects — including daytime sleepiness, foggy thinking, obesity, and depression — heavy drinkers who suddenly abstain tend to experience withdrawal symptoms that often include “severe insomnia,” shows research from the University of Michigan.

It’s safe to say the effect alcohol has on sleep is complex. But two things seem clear. First and foremost, heavy drinking harms sleep. But for people who don’t overdo it — and especially for those non-daily drinkers who suffer from insomnia — a nightcap now and then seems to benefit sleep. If you need more alcohol than that to get to sleep at night, you should consult a professional about your sleep issues, Roehrs says.