Re: simpleQuery method causes too many mysql change db commands

From: Date: Wed, 10 Aug 2005 16:26:40 +0000
Subject: Re: simpleQuery method causes too many mysql change db commands
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20352@lists.php.net to get a copy of this message
On 8/10/05, Ubaldo Huerta / gmail <ubaldo@gmail.com> wrote: > See in output of 'mytop' below that in my production server, 60% of all > commands are change db. So I track it down and noticed that in simpleQuery > there is database select even though in ::connect method the database is already > selected. > > Can anybody explain why is done this way? Should passing the connection > param to mysql_query call be sufficient? > AFAIR this is done because the various DB extensions (such as mysql) tend to set the database for *all* connections to a single server at once. This means if you have two "connections" to different databases on the same DB server you have to make sure the correct DB is selecte don each one *every* time you make a query. This could possibly be "fixed" in one of a few ways, but before going into that are you sure that this is affecting performance that much? 60% of the queries may be "change db queries" but I doubt 60% of the server's time is spent on it. It is, after all, only a simple context change and doesn't return any data or do any real querying. -- Justin Patrin

« previous php.pear.general (#20352) next »