Slow DB connection to external DB

For our dev sites we have a single external db and set this in wp-config.php

It works but is very slow (5mins+ for page download).

Have tested this speed to be due to remote db.

Have tried adding the following to my.cnf mysql config:

skip-external-locking
skip_name_resolve
skip_host_cach

But still no avail.

I also made sure to restart mysql by ssh:

service mysql restart

Any other ideas why this is occuring and how to speed up when connecting to an external db?

Cheers

Hi Elliot,

Did you configure the site to access the external database in wp-config.php?

Yep, that’s correct.

I can’t think of any particular reason why it would be slow. Editing the my.cnf won’t help though since that’s your Local MySQL.

One thing that might help is going to Help » Restart Local Machine. This might help since it’ll reset VirtualBox’s network device.

Still getting 16secs ttfb with external db.

When accessing db via Sequel Pro app it’s super fast.

Have setup using Mamp on another machine and it is fine too.

One thing I did notice. I have following code:

$server_name = $_SERVER['SERVER_NAME'];
 .....  } elseif ($server_name == 'wcg.dev') {

and then I add the db details here. So I can serve different db details for my local instance.

In the local site db panel/tab the db details for remote host are incorrect, because it is not following the above logic.

I don’t know if that is relevant or not. I suspect not.

Restarting the machine didn’t work either… I don’t suppose you have an external db you can test this with as it’s a big part of my dev work flow, so we don’t have the eternal problem of database conflicts.

Thanks

Elliot

Hmmm - restarted machine and now seems to be better. Not sure why as had restarted before…