Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL configuration for running tests faster

I want to speed up testing web applications by configuring MySQL.

I create web applications with PHP and MySQL. When developing, tests are run every time files are saved. Therefore, faster execution of tests saves development time and makes me feel comfortable.

Though there are sereval ways to speed up tests, its database must be one of them. As a testing environment, all I need is quicker response. I don't need durability or efficiency of handling multiple connections.

In that case, what is the best configuration?

like image 693
Akihiro HARAI Avatar asked May 13 '14 12:05

Akihiro HARAI


People also ask

What is MTR MySQL?

MySQL Test Run or MTR for short, is a MySQL test program. It was developed to ensure that the MySQL server's operation is as expected whether it be in terms of testing the functionality of new features or integrity of the old.

How do I test MySQL connection?

To test the connection to your database, run the telnet hostname port on your Looker server. For example, if you are running MySQL on the default port and your database name is mydb, the command would be telnet mydb 3306 . If the connection is working, you will see something similar to this: Trying 10.10.

What is MySQL test?

The mysqltest test engine checks the result codes from executing each SQL statement in the test input. If the failure is unexpected, the test case fails. A test case can fail if an error was expected but did not occur (for example, if an SQL statement succeeded when it should have failed).


1 Answers

It depends on test database setup.

If the database is running all the time, you'll have to tweak settings like buffer sizes and io threads. Like this answer suggests, there are tools that can test and produce recommandations for your server setup.

In unit tests where data integrity isn't that important, you can use in memory tables (ENGINE=MEMORY) and disable INNODB's double write (innodb_doublewrite=OFF). This will reduce data integrity but increase performance.

I'm using a library for setting up a the database every time the tests are run. By using these settings, the database are running in about a second:

  • innodb_fast_shutdown=2 (fast shut down)
  • innodb_log_file_size=1048576 (smallest possible log size)
  • innodb_data_file_path=ibdata1:10M;ibdata2:10M:autoextend (smallest possible data file sizes for quicker startup)
like image 64
StumpDK Avatar answered Sep 22 '22 14:09

StumpDK