NYCPHP Meetup

NYPHP.org

[nycphp-talk] Long MySQL processes, connections

Matt Roberts matt at matt-roberts.net
Mon Oct 24 14:47:41 EDT 2005



>I'd need more details to truly diagnose this (or even determine if there's
>something wrong).

Thanks Hans,

I did some performance tuning around my queries based on advice from this:
http://www.databasejournal.com/features/mysql/article.php/1382791

It seems to have sped up the routine significantly.

To boil it down to a "best practice" question: of the following two
routines, what is preferable in the general case?


Process A:
---------------------
Connect to mysql
for (~ 10k iterations){
    Query larger (500k rows) table in mysql
    Insert into same mysql
}
Disconnect from mysql
---------------------

Process B
---------------------
for (~ 10k iterations){
    Connect to mysql
    Query larger (500k rows) table in mysql
    Insert into same mysql
    Disconnect to mysql
}
----------------------



I've generally seen process A in all books I've read, but in my particular
example process B *seems* less error prone (but as you say Hans, it may
depend on many other details I'm leaving out here)

However, B looks kind of dumb and expensive to me - how costly is the
connect / disconnect operation?







----------------
m. roberts
matt at matt-roberts.net





More information about the talk mailing list