Re: RE: optimizing PHP for microseconds
| From: | Robert Cummings | Date: | Fri, 26 Mar 2010 06:17:13 +0000 |
| Subject: | Re: RE: optimizing PHP for microseconds | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-303497@lists.php.net to get a copy of this message | ||
Tommy Pham wrote:
On Thu, Mar 25, 2010 at 8:15 PM, Robert Cummings <robert@interjinn.com> wrote:This is possible but then you don't know whose query you are killing. A terminated PHP process or a actively running PHP process with a connected user awaiting output. However, you could track PHP process IDs and MySQL process IDs (via mysql_thread_id()) to know whose MySQL process you are killing. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHPDaevid Vincent wrote:What about 'SHOW FULL PROCESSLIST' and look through the 'INFO' for that last matching query statement and kill the process?That's a good point about MySQL, and in fact PHP would probably keep running too until MySQL returned. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP-----Original Message----- From: Robert Cummings [mailto:robert@interjinn.com] Sent: Thursday, March 25, 2010 7:16 PM Daevid Vincent wrote:Except there is no way to tell mySQL "cancel that last request/query". Well, no graceful way. We actually have a script that runs on a crontab and seeks and destroys "long running" queries. As you may have guessed, just because a query takes a long time, it's difficult to know if it's actually hung or just really taking that long. So we do some smarts to compare against others and see if it seems like the same one and stuff like that. Not great, but sure stops the load from shooting through the roof. Again, not going into the rant I've done before. Look in the archives 2009-06-02 for "Why doesn't mySQL stop a query when the browser tab is closed" for that thread and even more indepth info on the mysql@lists.mysql.com archives (same date and subject).If I have to wait 3 seconds for a page to render, that waitis noticeable.Dumb users will click refresh, and since (unbelievably inthis day and age)PHP and mySQL don't know the user clicked 'stop' or 'refresh', and therefore mySQL will execute the same query a second time. That's an entirely different thread I've already ranted on about.You may find the following enlightening:http://www.php.net/manual/en/function.ignore-user-abort.php http://www.php.net/manual/en/function.connection-aborted.php http://www.php.net/manual/en/function.connection-status.php