how to use is_admin in wp-config.php

I would be careful doing this, because you are assuming all your database modifications will only happen within the admin backend, but that might not always be the case. The wp-cron comes to mind, but there are also some plugins that use front-end writes. So you might get nasty sync problems with your two databases, using this method.

There are many things you can do before going the master/slave route:

  • Check for example your logs, if there’s anything strange going on there.
  • Maybe it’s a plugin that’s giving you problems?
  • Maybe you have a WP_Query that’s not efficient?
  • Maybe you can use the transients API?
  • Maybe you can consider persistant object cache?
  • There are many cache plugins out there that can help.
  • Maybe the hosting environment is slowing you down?
  • Maybe the MySQL server isn’t tuned well enough? Some helpful tuning scripts exists.
  • Maybe it’s time to update PHP, MySQL and start using NginX 😉

If you decide this route is necessary, there are already solutions out there, like the HyperDB plugin, that gives you a db.php drop-in to be placed in the wp-content directory. It checks for any writes/updates in the incoming SQL queries and redirects them to the master database. But I just scanned through the source and it looks like it’s not supporting the mysqli extension, only the deprecated mysql. If you don’t like forking this yourself, there seems to exists at least one fork that supports mysqli (I’m not related to this project).