How to optimize MySql database-personal summary

Binary tree: The query speed is fast, but it is prone to single branch.
Red-black tree (balanced binary tree): Based on the binary tree, the unbalanced binary will be adjusted to some extent.
B-tree: For tens of millions of data, the tree height is only 3 (16K–2 to the 14th power)
B+ number: On the basis of B number, some redundancy is added, but the range view speed is fast.
Hash: The search speed is the fastest , But the range search speed is slow

MySql database optimization-personal summary (InnoDB)

  1. Use numeric data types as much as possible, and numeric comparisons are much faster than character types.
  2. The data type should be as small as possible, for example, the stored mobile phone number can be fixed to 11 digits.
  3. Try not to use TEXT and IMAGE. If you store files, you can directly access them through nginx dynamic and static separation.
  4. Decide which tables need to add indexes according to the amount of data, and the small amount of data can only have the primary key
  5. Decide which fields need to be indexed according to the frequency of use
  6. Do not add too many indexes to a table, because indexes affect the speed of inserting and updating
  7. The index increases as much as possible. (The principle of B+number affects the insertion speed)
  8. Do not write SELECT * statements
  9. Do not write SQL statements without WHERE

Guess you like

Origin blog.csdn.net/xiaozhezhe0470/article/details/109608723