Database design and index optimization

Database design and index optimization

The MySQL database itself is highly flexible, resulting in insufficient performance, and it is heavily dependent on the developer's table design ability and index optimization ability. Here are some optimization suggestions

  • Time type is converted to timestamp format, stored in int type, index is built to increase query efficiency
  • It is recommended that the field definition is not null, null values ​​are difficult to query and optimize and occupy additional index space
  • Use TINYINT type instead of enumeration ENUM
  • To store accurate floating-point numbers, DECIMAL must be used instead of FLOAT and DOUBLE
  • The field length is seriously based on business needs, do not set too large
  • Try not to use the TEXT type. If you must use it, it is recommended to split the infrequently used large fields into other tables
  • MySQL has restrictions on the length of index fields. The length of each index column of the innodb engine is limited to 767 bytes (bytes) by default. The length of all index columns cannot be greater than 3072 bytes (mysql8.0 single index can create 1024 characters )
  • Please contact DBA when large tables have DDL requirements

Guess you like

Origin blog.csdn.net/qq_37557563/article/details/111575321