MySQL query progress information

I have a PHP script that executes a mysql query. I have an HTML / JQuery interface that initiates an asynchronous call (AJAX) in a script by requesting it eg. delete some data. I know my datapool is very small, but if it got bigger, I would like to display how many rows have been processed (since the estimated time is not shown until it is known).

This question is more theoretical than practical. Is there a way to find out how many rows have been processed while the request is supposedly still running?

It can be a delete or select statement.

My main question is, is it possible for one PHP script to execute a long request and another to return the status quo while it is still running when it is called? (for example, somehow retrieve the affected rows for a specific query, or something else?)

For the sake of simplicity, let's say I have 2 php files that I can call directly from my browser - one makes the request and the other presumably gets its status. Is it possible, and if someone could point me in the right direction? I might have to use some kind of stored procedure that at least reports the number of rows that have been processed?

+3


source to share


1 answer


This question is more theoretical than practical. Is there a way to find out how many rows have been processed while the request is supposedly still running?

Not native, but you can get around.

Is it possible for one php script to execute a long request and another to get the status quo while it is still running when it is called? (for example, somehow retrieve the affected rows for a specific query, or something else?)

These two scripts need to share a common storage location to "communicate", and you can use Redis for this purpose.



The script that makes the request also updates the value from Redis and another script reads the data from Redis and returns it to the browser.

An alternative would be to execute requests in batches (of 10, 20, etc.) and you can count the processed requests on the client side. In theory, if the script request does not return an error, it means that all requests are successful and you can increase the count value. You repeat the process until the request script returns a value of 0 executed requests, which means that you are done.

See this answer on SO and http://redis.io/ for details

+1


source







All Articles