You can improve the query speed by choosing the lighter datatype. Here are 2 tables with the following index structure.
PRIMARY KEY (`code`,`id`),
KEY `mnumber` (`mynumber`,`id`)
-rw-rw---- 1 mysql mysql 17G Mar 30 11:12 new_master.MYI
-rw-rw---- 1 mysql mysql 8.3G Mar 30 10:30 new_master.MYD
-rw-rw---- 1 mysql mysql 8.5K Mar 30 08:58 new_master.frm
-rw-rw---- 1 mysql mysql 18G Mar 27 21:23 master.MYI
-rw-rw---- 1 mysql mysql 8.8G Mar 27 20:55 master.MYD
-rw-rw---- 1 mysql mysql 8.5K Mar 27 17:55 master.frm
The Auto_incremented id column is of "integer" type in the master table and "mediumint" in the new_master. The difference of 1 byte makes a huge difference when there are 590 million records to be saved.
The reduction from 8.8 GB to 8.3GB was expected, but what was not expected was that the index size will come down to 17GB from 18GB. 1 Byte can reduce the index file size by almost 5-8%
Great!
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.