This is a discussion on What does 'Init DB' mean in the log? within the MySQL Database forums, part of the Database Forums category; Hi, this may sound like a stupid question, but I would like to know what 'Init DB' means in de ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi,
this may sound like a stupid question, but I would like to know what 'Init DB' means in de log of MySQL. I have a very bad performing application (we bought it). When I log all mysql-queries I can see a lot of 'Init DB'-messages - sometimes after every query. I don't think this is /the/ mayor reason this app is not performing, but I would still like to know what this means and /if/ it could be the perfomance hog... anybody? (The reason I am worried about it is that when I perform queryies manually on this server, the 'Init DB' allmost never shows up...) greetings, Paul |
|
|||
|
"profke" <pwiegers@gmail.com> wrote:
> > this may sound like a stupid question, but I would like to know what > 'Init DB' means in de log of MySQL. I have a very bad performing > application (we bought it). When I log all mysql-queries I can see a > lot of 'Init DB'-messages - sometimes after every query. I don't think > this is /the/ mayor reason this app is not performing, but I would > still like to know what this means and /if/ it could be the perfomance > hog... anybody? I guess you're talking about the general log of the MySQL server. 'Init DB' is logged for the mysql_select_db() API call. Having 'Init DB' right *before* each normal query is typical for PHP applications using a database abstraction layer. This is done to overcome a bug^Wmisconception in the PHP mysql extension. By default PHP shares database connections that use the same (host, user, pass) tupel. So if you do <?php $con1= mysql_connect($host, $user, $pass); mysql_select_db('foo', $con1); $con2= mysql_connect($host, $user, $pass); mysql_select_db('bar', $con2); ?> then the second call to mysql_select_db() will change *both* $con1 and $con2. To overcome this problem, all database abstraction classes issue mysql_select_db() right before each query. Normally this is *no* problem, because MySQL executes mysql_select_db() really fast. In praxis it's just sending one TCP packet to the server and receiving one packet as answer. Probably there is more impact on the performance by enabling the general log than by having those mysql_select_db(). If you want to spot bad queries, turn on the slow query log: http://dev.mysql.com/doc/refman/5.0/...query-log.html HTH, XL -- Axel Schwenke, Support Engineer, MySQL AB Online User Manual: http://dev.mysql.com/doc/refman/5.0/en/ MySQL User Forums: http://forums.mysql.com/ |
|
|||
|
Hi Axel,
> I guess you're talking about the general log of the MySQL server. That's right. > 'Init DB' is logged for the mysql_select_db() API call. Ah! Ok... > Probably there is more impact on the performance by enabling the > general log than by having those mysql_select_db(). If you want to > spot bad queries, turn on the slow query log:http://dev.mysql.com/doc/refman/5.0/...query-log.html I guest as much. Still, it is nice to know for sure! And I like to know what is happening om my servers, and, more importantly, for what reason. :-) Thank you for your elaborate answer! Paul |