Re: mysql online ddl still lock
Tables and INDEXes in InnoDB are stored in BTree structures.
INSERTs... When a block in a BTree must be split, 1 full block becomes 2 half-full blocks. Those blocks then fill up as you insert more rows. This gradually leads to the BTree being about 69% full.
DELETEs... InnoDB combines adjacent blocks that are less than half full.
A "point query" (SELECT ... WHERE primary_key = constant) is very efficient -- For a million-row table the BTree will be about 3 levels deep. The query will drill down those three blocks in the BTree. For a trillion-row table, it is about 6 levels. The number of levels rarely changes. That is, whether the table is fully defragmented or only 69% full, the number of levels is likely to be the same.
A "range query" (SELECT ... WHERE primary_key BETWEEN 123 AND 456) will do a point query to 123, then scan forward through the block(s) until the 456. True, if it is 100% full, it will need fewer blocks than if it is 69% full. But this has zero impact all the necessary blocks are cached.
MVCC -- "Multi version concurrency control" -- If you have two connections doing transactions that touch the same rows, InnoDB will (in certain circumstances) hang onto old records until a transaction finishes. That is, there can be "multiple versions" of a single row for a brief period of time. That can cause block splits that you don't expect.
But what about "Data_free" (from SHOW TABLE STATUS and `information_schema`)? It shows one of several types of "free" space. It does not show the "69%". There is not good way to measure the free space.
Do you want to defragment after every query? The cost of that is quite unreasonable. Don't bother doing OPTIMIZE -- ever.
Subject
Views
Written By
Posted
2617
February 19, 2016 02:35AM
1587
February 19, 2016 03:09AM
1528
February 19, 2016 06:53AM
1485
February 20, 2016 01:38AM
1224
August 24, 2016 03:48AM
1088
August 25, 2016 07:40PM
1244
August 30, 2016 09:33PM
1202
September 01, 2016 04:55PM
1144
September 01, 2016 11:40PM
1140
September 03, 2016 05:05PM
1142
September 05, 2016 01:20AM
1236
September 05, 2016 03:54PM
1036
September 08, 2016 04:04AM
1103
September 10, 2016 12:19AM
1412
February 23, 2016 11:29PM
1820
February 29, 2016 11:32PM
1588
March 05, 2016 12:19AM
1519
March 07, 2016 03:34AM
1494
March 31, 2016 02:32AM
1446
April 02, 2016 12:39AM
1470
May 13, 2016 02:44AM
Re: mysql online ddl still lock
1455
May 24, 2016 09:53AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.