java eight-part mysql optimization

Database Chapter-01-MySQL Chapter-Course Introduction_bilibili_bilibili

1. Positioning slow query

2. Analyze and optimize slow queries

3. Index concept and structure

 

3.1 Red-black tree (a self-balancing binary sorting tree)

The node can automatically balance to ensure log2 n search complexity.

But because it is a binary tree, there will be more layers if there is more data.

So find a multi-tree

3.2 B-tree

It is a multi-fork tree, relatively short and fat, and has higher search efficiency than red-black trees.

The stored numbers can be regarded as interval boundaries.

But if the value you want to check is on a leaf, and you check all the way down, the data on non-leaf nodes will also be loaded, so unnecessary data is read and written to the disk multiple times, so the disk cost is low.

---->The non-leaves of the B+ tree only have pointers and no data, so there is no need to load data all the way, just load it once to the leaf nodes.

3.3 B+ tree

Three major advantages:

1. There is no need to read node data when passing non-leaf nodes like B-tree. The non-leaves of B+ tree are pointer-oriented and will not waste disk reading and writing.

2. Searches are all done on leaves, and the basic efficiency is logn, which is stable.

3. Range search is convenient. For example, to find (6, 30), first find 6 on the leaf, and then find all the data in the range at once through the doubly linked list to avoid dfs

4. Clustered index, non-clustered index (secondary index)

 

5. Covering index

Database Chapter-06-Optimization-Covering Index, Extra Large Paging Optimization_bilibili_bilibili

 

 

6. Super large paging-->covering index + subquery (don’t quite understand)

7. Principles of index creation

8. Index failure

Just follow the order of your joint index.

To use the right one, you must have the left one and the order cannot be disordered. If it is broken in the middle, only the previous part that conforms to the leftmost principle will use the index.

Look at the key and keylen columns to know how many indexes are used. The more indexes there are, the larger the keylen is.

 

 

 -----------------------------

9. Various optimizations

-----------------

10. Affairs

11.SQL isolation level and concurrency issues

The problem is also a missing update 

12.undo log and redo log

Redo log is a physical log, which records forward operations.

 The undo log is a logical log that records the opposite statement of the operation and is used for undoing.

13.MVCC

This trx_id is the db_trx_id above, which represents the transaction number of the last record inserted or modified. 

If this number is not in the active set, it means that the transaction has been modified and submitted.

 

14. Mysql master-slave synchronization (read and write access pressure)

The master-slave synchronization of redis is incremental synchronization and full synchronization.

Mysql relies on the binary log binlog

15. Sub-database and table (large storage)

Guess you like

Origin blog.csdn.net/m0_50973548/article/details/135180916