Bluehost.com Web Hosting $6.95

What does 'Init DB' mean in the log?

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


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-15-2007
profke
 
Posts: n/a
Default What does 'Init DB' mean in the log?

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

Reply With Quote
  #2 (permalink)  
Old 03-15-2007
Axel Schwenke
 
Posts: n/a
Default Re: What does 'Init DB' mean in the log?

"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/
Reply With Quote
  #3 (permalink)  
Old 03-15-2007
profke
 
Posts: n/a
Default Re: What does 'Init DB' mean in the log?

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

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 07:03 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0