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
2353
February 19, 2016 02:35AM
1495
February 19, 2016 03:09AM
1383
February 19, 2016 06:53AM
1407
February 20, 2016 01:38AM
1122
August 24, 2016 03:48AM
1003
August 25, 2016 07:40PM
1153
August 30, 2016 09:33PM
1115
September 01, 2016 04:55PM
1056
September 01, 2016 11:40PM
1060
September 03, 2016 05:05PM
1054
September 05, 2016 01:20AM
1055
September 05, 2016 03:54PM
937
September 08, 2016 04:04AM
1009
September 10, 2016 12:19AM
1304
February 23, 2016 11:29PM
1643
February 29, 2016 11:32PM
1509
March 05, 2016 12:19AM
1418
March 07, 2016 03:34AM
1402
March 31, 2016 02:32AM
1352
April 02, 2016 12:39AM
1359
May 13, 2016 02:44AM
Re: mysql online ddl still lock
1265
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.