For people who die of opioid overdose in Massachusetts, the average survival time from the moment they take their first prescription painkiller is just 36 months, according to startling data released yesterday by the state public health commissioner.

“We have a really short window of time,” Dr. Monica Bharel told lawmakers as she presented findings of research into the opioid epidemic.

Compared to the general population, those who received three months of prescribed opioids in 2011 were four times as likely to die from an opioid-related overdose within one year and 30 times as likely to die of an overdose within five years, Bharel said.

However, there are signs that doctors have begun prescribing opioids less often in Massachusetts, she said, thanks partly to 7-day limits on such prescriptions, a prescription-monitoring database and efforts to educate prescribers.

In the third quarter of last year, for example, about 271,000 people received opioid prescriptions, a 30 percent decline from the first quarter of 2015, when 390,532 did, Bharel said.

That could be one reason why, after a 475 percent surge in opioid deaths from 379 in 2000 to 2,190 in 2016, the numbers declined by an estimated 10 percent to 1,470 in the first nine months of 2017, compared to 1,637 over the same period the year before.

But while the rate of prescription opioids and heroin present in opioid-related overdose deaths has declined, she said, the rate of fentanyl, which is 50 to 100 times more potent than heroin, in overdose deaths has soared, reaching 81 percent this year.

Certain demographics are particularly at risk. From 2014 to 2016, the age-adjusted, opioid-related fatal overdose rate for Hispanics, for example, doubled, Bharel said.

The opioid death rate for people with a history of incarceration is 120 times higher than that of those without one, she said, while the opioid death rate for homeless people is 30 times higher than the rate for those who are not homeless.

Officials have tried to prevent such deaths by making naloxone, which reverses overdoses, available to more first responders, among others, Bharel said.

Recognizing they also need to focus on prevention and treatment, health officials have launched a campaign to teach parents how to talk to their kids about opioid addiction, increased outpatient treatment sites from 14 three years ago to 45 today, and added 697 adult treatment beds since 2015, when an estimated 4.4 percent of Massachusetts residents ages 11 and older were diagnosed with an opioid-use disorder. Statewide, there also are more than 2,200 certified sober-home beds for addicts in recovery, said Ann Scales, a Department of Public Health spokeswoman.

Arlington police Chief Frederick Ryan praised Gov. Charlie Baker’s administration for that progress but said finding an addict a bed or a practitioner trained in medically assisted treatment such as methadone still can be “challenging.” Since 2010, his department has trained all 75 of its officers in behavioral-health and substance-abuse first aid and hired a clinician to work with them to help addicts and their families.

“It can take multiple calls and multiple attempts,” said Ryan, who said his department has gone from seeing about one fatal opioid overdose a month to a single suspected one in all of last year.

“We’re dogged at it because we know the alternative is likely a person’s death.”