What happens if we declare int(10) instead of int(1)? Does the performance change?

In MySQL, when you declare a column with the data type INT(10) instead of INT(1), there is actually no difference in terms of performance or how the data is stored in the database. Let me explain in detail so you can understand better:

1. Meaning of INT(n)

  • In MySQL, INT is a 4-byte (32-bit) integer data type, capable of storing values from -2,147,483,648 to 2,147,483,647 (for signed) or 0 to 4,294,967,295 (for unsigned).
  • The number in parentheses, such as INT(10) or INT(1), does not limit the length of the stored value. It only specifies the display width when you use tools like the MySQL CLI with the ZEROFILL option. Without ZEROFILL, this number has almost no practical significance in data storage or processing.

Example:

sql
CREATE TABLE test ( col1 INT(1), col2 INT(10) ); 
INSERT INTO test (col1, col2) VALUES (12345, 12345)
  • Both col1 and col2 can store the value 12345 without any truncation.
  • If you add ZEROFILL:
     
    • col1 INT(1) ZEROFILL will display as 0.
    • col2 INT(10) ZEROFILL will display as 0000012345.

2. Performance

  • There is no performance difference between INT(1) and INT(10). Why? Because both use exactly 4 bytes of memory to store the value, regardless of the number in parentheses. MySQL does not change the physical size of the data type based on the display width.
  • Performance only changes if you use a genuinely smaller data type like TINYINT (1 byte), SMALLINT (2 byte), or BIGINT (8 byte), as these directly affect storage size and processing speed in some cases.

3. When should you care?

  • If you need to save storage space (e.g., in a table with millions of records), choose a data type that matches the actual range of values:
     
    • TINYINT: -128 to 127 (or 0 to 255 if unsigned).
    • SMALLINT: -32,768 to 32,767.
    • INT: As mentioned above.
  • But if you’re just switching from INT(1) to INT(10), it has no impact on performance or storage.

Conclusion

Declaring INT(10) instead of INT(1) only affects the display (if you use ZEROFILL), but it doesn’t change how the data is stored or the performance of MySQL. If you’re not using ZEROFILL, the number in parentheses is mostly "decorative" and not something to worry about.

Working Contact Form with Ajax & PHP

Get a functional and working contact form with Ajax & PHP in a few minutes. Just copy and paste the files, add a little code and you’re done.

Download Now