Hudzilla.org - the homepage of Paul Hudson
Contents > Performance > Optimising your SQL Wish List | Report Bug | About Me ]

18.2.6     Change your hardware

This is NOT the latest copy of this book; click here for the latest version.

MySQL performance is very hardware dependent, and you can make a big difference in performance by either upgrading, or changing your setup - for example, spreading your database data across more than one disk can provide a drastic speed improvement by increasing the number of hard disk seeks a second MySQL can perform.

This might sound like an obvious way to make your code faster, and indeed it is: upgrading your system is likely to make the biggest immediate difference. Attitudes on what you should upgrade are mixed, with much of the conventional wisdom not really holding true any more. For example, MySQL recommend upgrading your RAM, then your hard drives, then your CPU. That may well be true in some circumstances, however the majority of us are likely to find the biggest speed difference by upgrading in the opposite order: CPU, hard drives, RAM.

The reason for this is because the "RAM first" recommendation is based upon the concept that you are likely to be filling up your RAM with your MySQL data. If you are indeed using up all your RAM with your databases, then upgrading your RAM will be a huge help. However, on the smaller of my two servers I have 512MB of RAM, and my databases (large as they are) only take up 200 - upgrading RAM will not change things a whit for me.

Upgrading your hard disk helps when committing data to disk and also reading data into RAM. If you can upgrade to a SCSI drive, or, better if you can stripe your data across several disks, you will see a noticeable speed up for your server. At the very least, consider using hdparm to tweak your settings. Try something like this:

hdparm -m16 -d1 -m1 -a1 /dev/hda
Author's Note: Using hdparm can damage or destroy your hardware - read the manual before use.

If your RAM isn't full and your hard disk aren't a problem - because they are fast enough or because they are not hit often - then it is CPU power that will count the most, and in my experience I have found sheer CPU horsepower is the key bottleneck. MySQL uses a lot of 64-bit integer code for its calculations, so if you can afford an Opteron or even an Athlon 64 you will find it makes a substantial difference.





<< 18.2.5 Use the EXPLAIN statement   18.2.7 Choose your data types carefully >>
Table of Contents
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.



My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!



Top-right shadow
 
Bottom-left shadow Bottom shadow

Comments from other readers
trt@hgjl.yt - 06 Sep 2008

<div title="ÃÃÃÃÃ"><A href="http://www.forex.co.ir/" title="ÃÃÃÃÃ"><IMG alt="ÃÃÃÃà ÃÃæÃà ÃæÃÃÃà ÃíÂäÃá ÃÃÃÂÃÃ" src="http://www.forex.co.ir/forex.gif"></A> <A href="http://www.meta-fx.com/" title="ÃÃÃÃÃ"><IMG alt="ÃÃÃÃà ÃÃæÃà ÃæÃÃÃà ÃíÂäÃá ÃÃÃÂÃÃ" src="http://www.meta-fx.com/forex.gif"></A></div>
http://www.forex.co.ir/
http://www.meta-fx.com/ ÙØ§Ø±Ùس

A PHP User - 06 Sep 2008

This is foolish advice --- if your mysql process isn't using up enough memory, try increasing the size of your key caches....

MySQL will use as much or as little memory as you give it. It can always use more, unless you're never hitting the disk.

Upgrade RAM first.

A PHP User - 06 Sep 2008

RAM filled with databases? It's filled up with processes.



Add comment
Please note that by posting a comment here you are committing it to the public domain. This is important so that others can make use of your code themselves, and also so that I can incorporate helpful notes directly into the main text. Comments are limited to 2000 characters in length.

If you are reporting an error in the content, please tell me directly.

Your name/email address:
Your comment:
 
Now, in order to verify that you're a real person, please answer this simple question: what is five plus four?
The answer is:
(please write in
numbers, eg 19)


Top-right shadow
 
Bottom-left shadow Bottom shadow