Answered slow mssql_select_db function

  • Wednesday, October 22, 2008 8:19 AM
     
     
    hi

    i dont know if my question is a little bit offtopic, but i have a problem with the standard mssql-php module.

    this statement is very slow with a large database (approx. 1GB)
    $dbhandle = mssql_connect($myServer, $myUser, $myPass) or die("Couldn't connect to SQL Server on $myServer");

    $start = microtime();   
    // select a database to work with
    $selected = mssql_select_db($myDB, $dbhandle) or die("Couldn't open database $myDB");
    $end = microtime();

    the difference between start and end is 0,8 sec.

    with a small DB it is
    0.001008 sec

    Does anybody have an idea, why it's like that and is it a problem of the php module or of the database itself.

    tia

    david

All Replies

  • Friday, October 24, 2008 9:47 PM
    Moderator
     
     Answered

    david-

     

    I was unable to reproduce your findings using our sqlsrv driver. That is, I could find no substantial difference in connection times based on the size of the database.

     

    I don't what the mssql driver is doing under the covers, but it may be that the select_db function is executing a USE dbName query to change the database. If you are using the connect function for one database, then using the select_db for the other, that might explain the difference in times. If this is not the case, I'd be interested in what you consider large and small databases, and in seeing the full script you are using for your testing.

     

    Hope that helps.

     

    -Brian