Hi,
first of all thanks for this module. It helps me a lot. I was unsure how to categorize this issue. It's not a bug in the means of producing errors but if I'm right with my opinion, than we have a performance issue here.

I saw that you're using db_set_active() to connect to the external database. I personally think that this is not a good practice, since it would block Drupal from running different queries against its own database and therefore blocks concurrent access to the site. There's also a Database::getConnection() method, which returns a database connection object that can be used for the external query.

I've tried and changed it. And it still works without any drawbacks. That's how my code looks like:

$conn = Database::getConnection('default', $source_config['database']);
      $result = $conn->query($query);

There's also a discussion about these two methods here: http://drupal.org/node/18429#comment-5509710

Comments

vkareh’s picture

Status: Active » Closed (works as designed)

db_set_active() is the correct way of connecting to a third-party database. Since Drupal bootstraps itself entirely with every HTTP request, there is no risk of blocking concurrent access to the database. For your single instance, of course, you would want to call db_set_active('default') after being done with the other database so that you can continue that request, but other requests are not affected by this.