Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
whoiami committed Oct 31, 2023
1 parent bdb13ff commit 0dd7bc5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion _posts/2023-10-30-PERCONA_RRE_COLUMN_COMPRESSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ mysql> CREATE TABLE t1(
### Code Analysis

列压缩在Percona上经过5.6-8.0的迭代主要的commit 如下,这里只以8.0版本做代码分析。

[Implemented "Column Compression with optional Predefined Dictionary"](https://github.com/percona/percona-server/commit/35d5d3faf00db7e32f48dcb39f776e43b83f1cb2)

[Compressed columns functionality merged from 5.6 to 5.7](https://github.com/percona/percona-server/commit/d142eb0ffc7301f638060181748a9ff1b9910761)

[Re-implement compression dictionaries in 8.0](https://github.com/percona/percona-server/commit/14e2a96c6954433970ce15b613dbbe85fb7239f0)


Expand Down Expand Up @@ -143,7 +146,9 @@ const byte *row_decompress_column(
字典信息是如何传入row_compress_column 函数里的呢?
mysql -h127.0.0.1 -uroot -P7788 -A (使用-A 参数use sbtest 的时候不会open table)
use sbtest;
INSERT INTO t1 VALUES (1, REPEAT('a', 200));
```c++
Expand Down Expand Up @@ -198,6 +203,7 @@ sql/dd/info_schema/metadata.cc
### Create Dict

SET @dictionary_data = 'one' 'two' 'three' 'four';

CREATE COMPRESSION_DICTIONARY numbers (@dictionary_data);

```
Expand Down Expand Up @@ -229,6 +235,7 @@ rea_create_base_table
### Insert & Select From Compressed Column

CREATE TABLE t1 (id INT PRIMARY KEY, b1 varchar(200) COLUMN_FORMAT COMPRESSED);

INSERT INTO t1 VALUES (1, REPEAT('a', 200));

```
Expand Down Expand Up @@ -276,9 +283,10 @@ select * from t1;
### Alter Column To Compressed Column (Copy DDL)

CREATE TABLE t1 (id INT PRIMARY KEY, b1 varchar(200) COLUMN_FORMAT COMPRESSED, b2 varchar(200));

INSERT INTO t1 VALUES (1, REPEAT('a', 200), REPEAT('a', 200));
ALTER TABLE t1 MODIFY COLUMN b2 varchar(200) COLUMN_FORMAT COMPRESSED;

ALTER TABLE t1 MODIFY COLUMN b2 varchar(200) COLUMN_FORMAT COMPRESSED;
这里走Copy ddl 先从原table 里面读出原有的record,再把需要修改的列压缩,之后写入一个新的table当中。这里原table有一部分列已经是压缩的了,所以读原table record的逻辑也会走到row_decompress_column。
完整的copy 逻辑在 copy_data_between_tables 函数内部。

Expand Down

0 comments on commit 0dd7bc5

Please sign in to comment.