MySQL Single Table optimization

Source: Internet
Author: User

First, table field optimization

1. Integer type try to use TINYINT, SMALLINT, Medium_int instead of INT, and non-negative numbers to add unsigned

2.VARCHAR length allocation should be reasonable, not too big

3. The time field does not exceed 2037 years using timestamp instead of datetime

4. It is best not to exceed 20 in a single table field

5. Field set default value, do not have null field

6.IP value is best converted to integral type when stored

Second, table index optimization

1. Proper indexing, based on the possible columns of where and ORDER by

2.SQL statements try to avoid NULL in the WHERE clause (the index is discarded and the full table is scanned)

3.

MySQL Single Table optimization

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.