php - MSSQL and PDO very slow -


i looking solution since days. found nothing worked...

i working on (cake) php application. on local machine, have mysql database. when connect database, queries fast.

when execute same code on server, microsoft server 2008 mssql, queries slow.

here little test specifies problem best:

$attrs = array(pdo::attr_persistent => true);  $dsn = 'sqlsrv:server=127.0.0.1;database=xxx_art_collection'; $user = 'xxx'; $password = 'xxx';  $start_time=microtime(true); try {     $dbh = new pdo($dsn, $user, $password, $attrs);      $statement = $dbh->prepare("select * items id<10000");     $statement->execute();      //$rows = $statement->fetchall(pdo::fetch_assoc);     //print_r($rows);      while ($row = $statement->fetch(pdo::fetch_assoc)) {         print_r($row['id']);     }  } catch (pdoexception $e) {     echo 'connection failed: ' . $e->getmessage(); } $stop_time=microtime(true); print_r('<br />'.number_format($stop_time-$start_time,4)); 

i have 1000 entries , measured time around 50 seconds.... on mysql 0.1 seconds...

thanks help...

assuming there no physical problem connection mssql server (low latency, network issues, etc) , there nothing wrong pdo driver, there should no such big difference.

as @sammitch said should index item.id field. try (nolock) hint. this:

select   *    items (nolock)   i.id < 10000 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -