How to Cancel SQL Queries when Browser stops loading page?

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

 



We sometimes experience slow ups because users who run queries via a browser
are retrying or stopping the query (by hitting the reload or stop buttons on the browser) 
before the queries complete.

This causes the creation multiple mysql processes each of which are running queries that will 
send their results out to the bit bucket.  Also, these "unattached" queries seem to run for much 
longer than if they are still part of a http session.  I tried turning off persistent mysql connections 
to no avail.  I tried registering a shutdown function to call mysql_close(), hoping this would stop the queries. 
This also seemed to have no effect.  

Is there a way to cancel  out these sql queries when the user hits stop or reload from the browser 
or to otherwise prevent the slowup that occurs when they do this? 
I am not sure whether this is more of a php or mysql issue.

We are using PHP and MYSQL on a Sun running Apache, but it works the same way on my Linux box.

PHP Version 4.0.6, Mysql Client API 3.23.24-beta, Mysql Version 3.23.40.


Thanks,
Peter

Example process list after hitting "stop" and "reload" several times.

------------------------------------------------+
| Id  | User     | Host      | db      | Command | Time | State          | Info
                                                |
+-----+----------+-----------+---------+---------+------+---------------+------

| 559 | xxxxxxxx | localhost |    test | Query   | 4    | Sorting result | selec
t * from rx WHERE traced = 1 ORDER BY ENTERDATE |
| 560 | xxxxxxxx | localhost |    test | Query   | 8    | Sorting result | selec
t * from rx WHERE traced = 1 ORDER BY ENTERDATE |
| 561 | xxxxxxxx | localhost |    test | Query   | 6    | Sorting result | selec
t * from rx WHERE traced = 1 ORDER BY ENTERDATE |
| 562 | xxxxxxxx | localhost |    test | Query   | 4    | Sorting result | selec
t * from rx WHERE traced = 1 ORDER BY ENTERDATE |
| 563 | xxxxxxxx | localhost |    test | Query   | 3    | Sorting result | selec
t * from rx WHERE traced = 1 ORDER BY ENTERDATE |




-- 
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