Health Desk: May 10, 2017: The paper, published in The BMJ, builds on a previous body of work linking these drugs to heart problems.
This research suggests the risk could be greatest in the first 30 days of taking the drugs.
But scientists say the findings are not clear cut. They say other factors - not just the pills - could be involved.
In the study an international team of scientists analysed data from 446,763 people to try to understand when heart problems might arise.
They focused on people prescribed non-steroidal anti-inflammatory drugs (such as ibuprofen, diclofenac, celecoxib and naproxen) by doctors rather than those who bought the painkillers over the counter.
Studying the data from Canada, Finland and the UK, researchers suggest taking Nsaids to treat pain and inflammation could raise the risk of heart attacks even in the first week of use and especially in the first month when taking high doses.
But scientists say there are a number of factors that make it difficult to be absolutely certain of the link.
Are the painkillers definitely to blame?
Kevin McConway, emeritus professor of statistics at The Open University, said the paper threw some light on possible relationships between Nsaid painkillers and heart attacks.
But he added: "Despite the large number of patients involved, some aspects do still remain pretty unclear.
"It remains possible that the painkillers aren't actually the cause of the extra heart attacks."
He said if, for example, someone was prescribed a high dose of a painkiller because of severe pain, and then had a heart attack in the following week, it would be "pretty hard" to tell whether the heart attack had been caused by the painkiller or by whatever was the reason for prescribing it in the first place,
It could even be down to something else entirely, he said.
Prof McConway also pointed out that other influences on heart health - such as smoking and obesity - could not be taken into account fully and could be partly to blame.
What should patients do?
Doctors are already aware from previous studies that non-steroidal anti-inflammatory drugs could increase the risk of heart problems and strokes.
And current UK guidelines state that Nsaids must be used carefully in people with heart problems and in some cases (such as very severe heart failure) they should not be used at all.
Dr Mike Knapton of the British Heart Foundation, suggests patients and doctors weigh up the risks and benefits of taking high doses of these common painkillers, particularly if they have survived a heart attack or are at higher risk.
Meanwhile, GP leader Prof Helen Stokes-Lampard said it was important that any decision to prescribe was based on a patient's individual circumstances and medical history, and was regularly reviewed.
She said that as new research was published, it was important that it was taken on board to help inform guidelines.
But she added: "The use of Nsaids in general practice to treat patients with chronic pain is reducing, and some of the drugs in this study are no longer routinely prescribed in the UK, such as coxibs, as we know that long-term use can lead to serious side-effects for some patients.
What about over-the-counter use?
This paper looks at patients prescribed painkillers rather than people buying them in a shop or taking them without medical advice.
But Prof Helen Stokes-Lampard said the study should also raise awareness among patients who self-medicated with Nsaids to treat their pain.
According to NHS advice, people should generally take the lowest dose of Nsaids for the shortest time possible.
And if people find they need to take Nsaids very often or are taking higher doses than recommended, medical advice should be sought.
How big are the risks?
Independent researchers say one of the main pitfalls of the study is it does not clearly spell out what the absolute risk - or the baseline risk of people having a heart attacks - is.
And they say without an understanding of the baseline, it is then hard to judge the impact of any possible increase in risk.
Meanwhile, Prof Stephen Evans, of the London School of Hygiene and Tropical Medicine, said though the study indicated that even a few days' use was associated with an increased risk, it might not be as clear as the authors suggested.
He added: "The two main issues are that the risks are relatively small, and for most people who are not at high risk of a heart attack, these findings have minimal implications."