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