Question

I'm php project which bases on two seperate databases. One is MySQL DB and the other one is on Microsoft SQL-server. Basicly I've configured whole environment and it works almost fine.

Almost, because I've noticed some terrible performance while trying to access both DBs.

My DB Config generated by propel looks like this:

$conf = array (
  'datasources' => 
  array (
    'db1' => 
    array (
      'adapter' => 'sqlsrv',
      'connection' => 
      array (
        'dsn' => 'sqlsrv:server=SERVER_NAME\\SQLEXPRESS;Database=db1',
        'user' => 'user1',
        'password' => 'password1',
      ),
    ),
    'db2' => 
    array (
      'adapter' => 'mysql',
      'connection' => 
      array (
        'dsn' => 'mysql:host=localhost;dbname=db2',
        'user' => 'user2',
        'password' => 'password2',
        'settings' => 
        array (
          'charset' => 
          array (
            'value' => 'utf8',
          ),
        ),
      ),
    ),
    'default' => 'db1',
  ),
  'log' => 
  array (
    'ident' => 'my_id',
    'type' => 'file',
    'name' => './../application/logs/propel.log',
    'level' => '7',
    'conf' => '',
  ),
  'generator_version' => '1.6.7',
);

I've checked the propel.log, but i noticed that only queries from db1 were logged there. So I used my own text file log class, to log response times. Whenever I've tried to get data from db2, response time was around 1s, which is unacceptable.

After that I tried to work on db2 seperately and same query took around 0.07s! So i figured that propel is causing delay while switching connections.

I performed second test - i've set db2 as default in propel config. When i did that, queries from db2 were performed much faster (again - same query 0.07s).

Is it normal behaviour? Does working on multiple databases always cause performance issues?

Is it anyway to make it faster?

Thanks in advance for any help. I'd be more than happy to provide some additional details if required.

Était-ce utile?

La solution

Found the solution. It was completly different reason: http://www.iishacks.com/2013/02/18/mysql-connection-response-slow-on-windows-2008-2012/

Sorry for wasting your time.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top