Answers.Body: <p>If you only ever connected to one database on the same database server yes. If you run e.g. drupal and civi in different databases on the same server you will have problems. Even if you don't, it's theoretically possible a 3rd party civi extension uses its own separate database (but probably rare).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-09T06:34:05.467Z
Answers.Text: I have a wp site with separate databases for wp and civicrm. Acording to http://php.net/manual/en/function.mysql-connect.php the same connection will be reused if the same parameters are given to the connect. So I don't see why it would cause problems. Could you explain? And if what you say is true, then if I use the same db can I drop that (even if WP is no longer using mysql but mysqli?
Answers.UserDisplayName: Franky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-09T16:28:47.357Z
Answers.Text: mysql_connect doesn't specify the database. The currently active database for a given connection can get clobbered if re-using connections.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-09T16:32:37.737Z
Answers.Text: I am not sure about how it works when mixing mysqli and mysql, but you might rarely still have a problem with unusual extensions. Are you running into resource problems? It seems unlikely new_link would be the biggest factor.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-10T06:50:16.637Z
Answers.Text: Well, my wp and civicrm are on the same db server (installed by my hosting provider), but while my regular wordpress is snappy, the civicrm pages can be slooow ... even without any contacts in it at all.
Answers.UserDisplayName: Franky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-10T06:56:43.777Z
Answers.Text: So I'm looking at all possible factors. Is mysqli already stable in civicrm (and is it any faster than mysql)? I'm hoping for php7 in 4.7.12 :-)
Answers.UserDisplayName: Franky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-10T13:40:46.700Z
Answers.Text: You should switch to mysqli (https://civicrm.org/blog/totten/psa-please-verify-php-extension-mysqli), but it's unlikely to make any noticeable performance difference. Civi has higher minimum requirements than wordpress - does your server have enough RAM? Is it shared hosting or at least a VPS?
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-11T15:36:31.360Z
Answers.Text: It is shared hosting, but they advertise civicrm hosting+support(not that I need the latter). But I'll switch to mysqli already (if it is fully supported it should be made a bit more clear ...). And I know mysqli no longer uses "new_link" in its dsn, but it is like the standard.
  Although like I said: regular wp pages and all other admin pages are very snappy, and *sometimes* civicrm too :-)
Answers.UserDisplayName: Franky
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-09-09T03:03:17.633Z
Answers.LastActivityDate: 2016-09-09T03:03:17.633Z
Answers.UserDisplayName: Demerit
Body: <p>I see that in all civicrm settings.php examples the DSN is something like</p>
  
  <blockquote>
    <p>mysql://crm_db_username:crm_db_password@db_server/crm_database?new_link=true</p>
  </blockquote>
  
  <p>but why the new_link setting? Isn't it much more efficient to re-use an existing mysql connection than to open a new one each time?</p>
  
Tags: <civicrm.settings.php>
Title: Why do we need new_link in the mysql DSN settings?
ThreadText: # Why do we need new_link in the mysql DSN settings?
  
  (Asked by: username_0 on 2016-09-08)
  
  I see that in all civicrm settings.php examples the DSN is something like
  
  > mysql://crm\_db\_username:crm\_db\_password@db\_server/crm\_database?new\_link=true
  
  but why the new\_link setting? Isn't it much more efficient to re-use an existing mysql connection than to open a new one each time?
  
  **Tags:** civicrm.settings.php
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-09-09. Score: 1
  
  If you only ever connected to one database on the same database server yes. If you run e.g. drupal and civi in different databases on the same server you will have problems. Even if you don't, it's theoretically possible a 3rd party civi extension uses its own separate database (but probably rare).
  
  > **Comments:**
  > **username_0**: I have a wp site with separate databases for wp and civicrm. Acording to http://php.net/manual/en/function.mysql-connect.php the same connection will be reused if the same parameters are given to the connect. So I don't see why it would cause problems. Could you explain? And if what you say is true, then if I use the same db can I drop that (even if WP is no longer using mysql but mysqli?  
  > **username_1**: mysql_connect doesn't specify the database. The currently active database for a given connection can get clobbered if re-using connections.  
  > **username_1**: I am not sure about how it works when mixing mysqli and mysql, but you might rarely still have a problem with unusual extensions. Are you running into resource problems? It seems unlikely new_link would be the biggest factor.  
  > **username_0**: Well, my wp and civicrm are on the same db server (installed by my hosting provider), but while my regular wordpress is snappy, the civicrm pages can be slooow ... even without any contacts in it at all.  
  > **username_0**: So I'm looking at all possible factors. Is mysqli already stable in civicrm (and is it any faster than mysql)? I'm hoping for php7 in 4.7.12 :-)  
  > **username_1**: You should switch to mysqli (https://civicrm.org/blog/totten/psa-please-verify-php-extension-mysqli), but it's unlikely to make any noticeable performance difference. Civi has higher minimum requirements than wordpress - does your server have enough RAM? Is it shared hosting or at least a VPS?  
  > **username_0**: It is shared hosting, but they advertise civicrm hosting+support(not that I need the latter). But I'll switch to mysqli already (if it is fully supported it should be made a bit more clear ...). And I know mysqli no longer uses "new_link" in its dsn, but it is like the standard. Although like I said: regular wp pages and all other admin pages are very snappy, and *sometimes* civicrm too :-)  
  
  ---
  
  