TransWikia.com

Avoiding duplicate MySQL queries in different processes

Super User Asked by Murilo Schmalfuss on November 29, 2021

Is there a way to configure MySQL to avoid two or more identical queries at the same time? e.g. a user generates a report and enters the same page again and generates the same report. The processlist command in the mysql client shows the same query executed by different processes.

One Answer

As it is always delicate to give a full no-no, your question is not easy to answer. Though, AFAIK, literally the answer is indeed NO.

Having said this, one could image some (complex) ways to embedd the query into some larger statement which implies some kind of locking mechanism - but you did not ask for this. And frankly said, it is not something I would recommend.

I guess that actually you are looking for a beneficial way to prevent such queries running in parallel for the same data by the same user. My approach would be to prevent this by some other mechanism (raw database/table locking would not be attractive for me) - probably in the application's logic (e.g. binding the running query into the user's session or similar).

Answered by fratester on November 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP