A novel data-mining project reveals evidence that a common group of heartburn medications taken by millions of people is associated with a greater risk of heart attacks, Stanford University researchers reported Wednesday.

After combing through 16 million electronic records of 2.9 million patients in two separate databases, the researchers found that people who take the medication to suppress the release of stomach acid are 16 percent to 21 percent more likely to suffer myocardial infarction, commonly known as heart attack.

Because of its design, the study could not show cause and effect, but the researchers did claim that if their technology had been available, "such pharmacovigilance algorithms could have flagged this risk as early as the year 2000."

The link between the drugs, known as proton pump inhibitors, and heart attacks is strong enough that "we do think patients should think about their risks and benefits and should discuss their risk with their doctors," said Nicholas J. Leeper, an assistant professor of cardiovascular medicine and vascular surgery at Stanford, and one of the authors of the study. The danger extends to people outside high-risk groups, such as the elderly.

Leeper said the Food and Drug Administration "should be aware of these findings," but agreed that only a large, prospective clinical study -- the gold standard of medical research -- could establish whether the drugs are actually causing more heart attacks.

Because some of the medications are now available over the counter, "if you are taking these for more than two weeks without telling your doctor, tell your doctor," said Nigam Shah, an assistant professor for biomedical informatics and the lead author of the research.

Proton pump inhibitors such as Nexium, Prilosec and Prevacid are among the most widely used drugs in the world. According to the study, an estimated 113 million prescriptions for the drugs are written for them around the world each year. In the United States, about 21 million people used one or more of them by prescription in 2009. When over-the-counter versions are added, worldwide sales total $13 billion annually, according to the paper.

According to IMS Health, a global information and technology services company, the top 10 prescription versions of these drugs accounted for $9.2 billion in U.S. sales in 2014, down from $12.3 billion in 2010. The data does not include over the counter sales. Nexium, the top seller in the prescription group last year, became available over the counter in May 0f 2014, which helped reduce the use of prescription versions, according to Express Scripts, another analyst of the drug market.

The medications work by blocking the secretion of acid into the stomach to reduce or eliminate heartburn, known technically as gastroesophogeal reflux disease, and have been widely considered effective, with few side effects except among people taking a blood thinner, clopidogrel. The study excluded people on that drug, also known as Plavix.

They were developed after another group of drugs that includes Zantac and Pepcid, which combat heartburn in a different way, by blocking histamine production in those same cells that line the stomach. The Stanford study found no association between those medications and increased risk of heart attack.

Telephone calls and e-mails to Novartis, AstraZeneca and Procter & Gamble, pharmaceutical companies that make or distribute prescription and over-the-counter versions of the drugs, were not returned by Wednesday at 2 p.m., when the peer-reviewed study was published online in the journal PLOS One.

The research theorizes that proton pump inhibitors may reduce production of nitric oxide from cells that line the inside of the circulatory system, including the heart. Lower levels of nitric oxide have long been associated with cardiovascular problems, Leeper said. Stanford researchers are testing the theory in the lab.

Shah's team scoured 11 million electronic medical records for 1.8 million patients who were seen between 1994 and 2011 at Stanford medical facilities. To ensure that they were not seeing only the sickest patients, they also reviewed 5.5 million records for 1.1 million patients seen at small practices around the country between 2007 and 2012. Those records are contained in a database called Practice Fusion.

From those two populations, they identified 70,000 and 227,000 people, respectively, who were suffering from heartburn. They compared the frequency of heart attacks among those who were prescribed or using proton pump inhibitors against people who were not using the medication.

Finally, they looked at records of 1,503 people in another, ongoing study who had suffered heart attacks, cardiac arrest, stroke, heart failure or a ruptured aneurysm to determine how many were using proton pump inhibitors.

They also noted a study in their paper that showed for every 4,357 people who used proton pump inhibitors for 14 days, there would be one additional heart attack when compared with those not using the drugs.

The work is not the first to use data mining to uncover medication problems that had escaped researchers who conducted traditional clinical trials. In 2004, the blockbuster pain-reliever Vioxx was pulled from the market after the FDA and Kaiser Permanente analyzed 1.4 million Kaiser patient records and determined that heart attack and cardiac death rates were three times higher for people taking the medication than a rival drug.

Data mining also has been used to detect whether people who take two drugs simultaneously might suffer side effects that neither drug would cause on its own.

Leeper said the new study is not meant to be seen as "anti-drug company at all."

"Clinical research has gotten so expensive, it's just prohibitive, even for these [drug] companies," he said. "It's just impossible to pick up every side effect."

Nevertheless, he added, "we think that this risk is real, and it ought to be investigated."