NYCPHP Meetup

NYPHP.org

[nycphp-talk] talk Digest, Vol 29, Issue 42

Douglas Clifton dwclifton at gmail.com
Thu Oct 27 00:19:56 EDT 2005


Connecting is expensive, connecting over a wire is
VERY expensive. Consider a persistent connection.

> ---------- Forwarded message ----------
> From: "Matt Roberts" <matt at matt-roberts.net>
> To: talk at lists.nyphp.org
> Date: Mon, 24 Oct 2005 14:47:41 -0400 (EDT)
> Subject: Re: [nycphp-talk] Long MySQL processes, connections

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

--
Douglas Clifton
dwclifton at gmail.com
http://loadaveragezero.com/
http://loadaveragezero.com/app/s9y/
http://loadaveragezero.com/drx/rss/recent



More information about the talk mailing list