Softpedia
 

NEWS CATEGORIES:



NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
Home > News > Webmaster > Tips and Tricks

September 24th, 2007, 14:59 GMT · By Adrian Placinta

How to Optimize Your MySQL Data Files

SHARE:

Adjust text size:



Enlarge picture
The first method to optimize your database is to make the tables for it as small as you possibly can. If you manage to do this, disk reads are faster, and smaller tables normally require less main memory while their contents are being actively processed during query execution. If the columns are also very small the indexing will work smoothly, without using many resources.
Another way to optimize your database is to choose the table format that will give you a big performance boost.

Declaring columns to be NOT NULL will save one bit per column. This doesn't mean that you can use NULL in your application. If you need it, use it; just avoid to use it in every column. Another way to optimize tables minimizing the disk space used is to employ the smallest data types possible. For example, MEDIUMINT is often a better choice than INT because a MEDIUMINT column uses 25% less space.

Also, make sure the primary index of the table is as short as possible. This will make the identification of the rows more efficient. Creating indexes only if you need it is also a good solution for optimization. If you use many indexes, that will affect the data storing speed. To obtain better compression of the index, use first the column with more duplicates. You should remember that shorter indexes are faster, not only because they require less disk space, but because they also give you more hits in the index cache and fewer disk seeks.

If you use MyISAM tables you should apply a fixed-size row format only if you don't have any variable-length columns. This method is faster, but unfortunately, it may waste some space. Using CREATE TABLE option ROW_FORMAT=FIXED you can hint that you want to have fixed length rows even if you have VARCHAR columns.

Because MySQL uses so many storage engines and row formats, make sure you use the proper table format and indexing method.
FILED UNDER:
MySQL
optimize
database
tables

TELL US WHAT YOU THINK:

1,658 hits · Link to this article · Print article · Send to friend · Subscribe to news

MUST-READ RELATED ARTICLES:


MySQL Query Browser

MySQL Migration Toolkit

Install Multiple MySQL Services

How to Copy an MYSQL Database from One Computer to Another

Could Login Passwords Be Cracked?

READER COMMENTS:



No user comments yet.
Be the first to express your opinion!
Copyright © 2001-2012 Softpedia. Contact/Tip us at

WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM