MySQL 5.0 Reference Manual  /  Data Types  /  Choosing the Right Type for a Column

11.8 Choosing the Right Type for a Column

For optimum storage, you should try to use the most precise type in all cases. For example, if an integer column is used for values in the range from 1 to 99999, MEDIUMINT UNSIGNED is the best type. Of the types that represent all the required values, this type uses the least amount of storage.

Tables created in MySQL 5.0.3 and above use a new storage format for DECIMAL columns. All basic calculations (+, -, *, and /) with DECIMAL columns are done with precision of 65 decimal (base 10) digits. See Section 11.1.1, “Numeric Type Overview”.

Prior to MySQL 5.0.3, calculations on DECIMAL values are performed using double-precision operations. If accuracy is not too important or if speed is the highest priority, the DOUBLE type may be good enough. For high precision, you can always convert to a fixed-point type stored in a BIGINT. This enables you to do all calculations with 64-bit integers and then convert results back to floating-point values as necessary.

PROCEDURE ANALYSE can be used to obtain suggestions for optimal column data types. For more information, see Section, “Using PROCEDURE ANALYSE”.

Download this Manual
User Comments
  Posted by Martin Feuchtwanger on August 29, 2008
Instead of

"For the most efficient use of storage, try to use the MOST precise type in all cases."

I think it should be

"For the most efficient use of storage, try to use the LEAST precise type THAT WILL ACCOMMODATE ALL POSSIBLE VALUES in all cases."

(EMPHASIS made just to highlight the difference.)
  Posted by Jalil Latiff on February 11, 2012
i think the precision he meant refers to the TYPE rather than the numbers. If you have numeric data for example, you can also store it as string, but it would be more precise to store it as the relevant numeric type, as it would be more efficient.
Sign Up Login You must be logged in to post a comment.