0

I have a local website running that will query a mysql database via inputs given by a html form. The form values are sent to php via jQuery to call the query. Is there a way to send a command to the mysql server to kill the query if the website is refresh?

Currently if I refresh, the last mysql call will still run, so the website will be locked up until that query is finished.

Edit: To give a little more background information on the website, it is a local website that is solely running d3 visualizations based on a series of involved queries (lots of full text searches) on a large database (3 tables all in the 1 - 5 million record range). The "lockout" I'm referring to is not being able to abandon a query and try a more efficient query (i.e. something that will limit my results more).

Rich
  • 905
  • 1
  • 6
  • 10
  • 1
    Why not fix your query? Why do you have a query that takes so long to run? – Mike Brant Dec 04 '14 at 15:02
  • This question/answer addresses your question: http://stackoverflow.com/questions/14892874/mysql-close-connect-can-not-halt-the-insert-activity – Peter Dec 04 '14 at 15:08

1 Answers1

1

Perhaps there is (it generally involves selecting the last process ID from the MySQL Processlist and issuing KILL QUERY on that process ID), but there are some problems that I think you should try to address first.

To begin, why in the world does one query "lock up" a website? I might be smelling a design flaw.

JavaScript could be used to make the browser "hit" the server on a refresh, but that's just adding another AJAX call and, presumably, another MySQL query (having to do with the processlist) and more PHP to write to handle the AJAX call, the processlist lookup, and the KILL QUERY query ...

I would recommend you try and make the server/MySQL query more efficient, so that you don't have to get a flying flip whether the browser is refreshed or not. As for browser security, you could probably use either PHP or JavaScript to enforce some sort of "flood limit" on repeated refreshing ....

Kevin_Kinsey
  • 2,285
  • 1
  • 22
  • 23