Two MySQL tuner scripts

MySQLTuner (Perl) and MySQL Performance Tuning Primer (Shell) are two scripts that can help diagnose MySQL database performance issues, and provide recommendations on how to solve them.  While both scripts output similar information, the diagnosis can be slightly different with each script, so I like to use both.  Below are directions on how to use them, as well as a few screenshots.

# Download MySQLTuner and MySQL Performance Tuning Primer to ~/scripts.
# To avoid having to invoke Perl/SH each time, make both files executable.
chmod +x ~/scripts/mysqltuner.pl
chmod +x ~/scripts/tuning-primer.sh

# After that, give them a go!
~/scripts/mysqltuner.pl
~/scripts/tuning-primer.sh

tuning-primer.sh

Configure Apache, PHP, and MySQL for performance

Make sure that your configuration files are setup correctly for your server, application, and load.  Enough said?

Best Practices

Did you know that incrementing a class variable is three times slower than incrementing a local variable?  Did you know adding LIMIT 1 to SQL queries for a single row can speed up queries?  Simply changing the way you write code can speed things up considerably.

Get a PHP opcode cache

PHP is an interpreted language, and as such it must be “compiled” into a readable format called opcode.  An opcode cache basically preserves the compiled data, and allows us to essentially skip a step.  This can save much needed resources (CPU, memory, etc.), and lower load time considerably.

Share