Mysql – Can moving tables to another MySQL database help performance

MySQLperformanceperformance-tuning

I want to know if I using different databases can help performance.

I have one big table support_chat with more than 5 million rows. I need to scan this all the time (3s with ajax) to check new messages on support.

If I move this table to another database in the same computer, can it help anything? (let users, sells, comments table faster)

For example:

db1

users table
sells table
comments table
support_chat table // move this table to db2

db2

support_chat table

They want to keep old things due legal reasons, to have a user support history.

Best Answer

Generally, no. A few tangentially related things to note though:

  1. You could use a symlink to move the /<datadir>/db2/ directory to another storage/block device. Or you could use the CREATE TABLE ... DATADIR=/../ option to move only the support_chat table to another storage/block device. That could make a big difference, assuming that you're frequently disk bound.

  2. With MySQL 5.6, using multiple databases/schemas can help to improve slave throughput (assuming you're using replication) because the parallelization was at the schema level:

    Replication Slave Options and Variables --slave-parallel-workers

    So with three databases/schemas, you would benefit from setting slave-parallel-workers=3.

For more info on the multi-threaded slave work in MySQL 5.6:

MySQL Replication High Performance: Multi-Threaded Slaves and Group Commit (pdf)

Just FYI, the multi-threaded slave behavior has been greatly improved in MySQL 5.7 too, the biggest example being that you can now instead use (Lamport) logical clock based parallelization:

Replication Slave Options and Variables --slave-parallel-type