MySQL column type selection

Source: Internet
Author: User


For example, the age of this field can be used 1990-03-15 also can be expressed in 19900315
You can select char and int on the column type;
If a field can select more than one type, try to choose a faster type;
Field-type precedence integer >DATE,TIME>CHAR,VARCHAR>BLOB
Integral type, time operation fast, space saving
Char/varchar to consider the conversion of the character set and the collation set of sorting, the speed is slow
BLOB cannot use memory temp table
The enum type is stored internally using an integer type, so the speed is the same as int, but note that if the enum stores the string and the Char type field
Correlation query, enum internal need a conversion, take time, enum and Char column association speed is slower than char and char, but also depends on the situation of specific analysis;

If you're sure you want to use int, consider whether you can use Smallint/tinyint,
Be able to solve char (10) not with char (20), not too generous;

Try to avoid using null
Null is not conducive to the index, to be labeled with special bytes, the space occupied on the disk is actually greater.

MySQL column type selection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.