RE: Long running db queries and the "STOP" button

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Few things I can think of:

1. warn the user that the query may take some time and then show a splash type screen that indicates that something is happening

2. Run the whole thing in a new window without the toolbar

3. rework the query so it doesn't take so much time. If there are a lot of joins in the query, you need to re-order the joins to make the combinations more efficient, perhaps break up the queries and place the individual results in array. Then manipulate the arrays to show the data how you want. (I did this to great effect to get a 4 minute query down to 10 seconds)

Bastien


From: <Thomas.Seiler@xxxxxxxxxxxx>
To: <php-db@xxxxxxxxxxxxx>
Subject:  Long running db queries and the "STOP" button
Date: Thu, 27 Oct 2005 16:03:58 +0200

Hello list,

We are working on a project where we use PHP5 inside Apache2 and run very long running queries on mysql 5 and postgresql. A single query might run up to several minutes, and generally uses 100% CPU on the database server. So far everything is fine.

Now what happens, is that sometimes the user hits the stop / back button before the query completes and reissues a new one. The result is that two queries are running on the database server, even though the results of the first query will never be used. Furthermore as both queries are concurring for the CPU, the second query takes much longer than normal.

PHP will only realize that the connection was closed by the browser once the database query is completed, but not during the query itself.

What we are looking for is a way to cancel a running query immediately when the user hits the back / stop button on his browser.
We found no real solution for this problem in the usual places.

Any ideas, thoughts or comments are very welcome!

Cheers,
Thomas

---------------------------------------------
Thomas Seiler
Ing. sys. com. dipl. EPFL
SWISSCOM AG
Innovations
Security and Service Management
Ostermundigenstrasse 93
CH - 3050 Bern
SWITZERLAND
 
Phone:  +41 (0)31 342 42 69
Mobile: +41 (0)79 427 97 26
Fax:    +41 (0)31 892 62 27

Thomas.Seiler@xxxxxxxxxxxx
http://www.swisscom.com

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux