Re: RE: optimizing PHP for microseconds

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

 



Tommy Pham wrote:
On Thu, Mar 25, 2010 at 8:15 PM, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
Daevid Vincent wrote:

-----Original Message-----
From: Robert Cummings [mailto:robert@xxxxxxxxxxxxx] Sent: Thursday, March
25, 2010 7:16 PM

Daevid Vincent wrote:
If I have to wait 3 seconds for a page to render, that wait
is noticeable.
Dumb users will click refresh, and since (unbelievably in
this 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

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@xxxxxxxxxxxxxxx archives (same date and subject).
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


What about 'SHOW FULL PROCESSLIST' and look through the 'INFO' for
that last matching query statement and kill the process?

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 PHP

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux