Column Compression with optional Predefined Dictionary
https:/
Column-level compression for Percona Server
*******
Feature highlights:
SET @dictionary_data = 'one' 'two' 'three' 'four';
CREATE COMPRESSION_
CREATE TABLE t1(
id INT,
a BLOB COLUMN_FORMAT COMPRESSED,
b BLOB COLUMN_FORMAT COMPRESSED WITH COMPRESSION_
) ENGINE=InnoDB;
SET @json_value =
'[\n'
' {\n'
' "one" = 0,\n'
' "two" = 0,\n'
' "three" = 0,\n'
' "four" = 0\n'
' },\n'
' {\n'
' "one" = 0,\n'
' "two" = 0,\n'
' "three" = 0,\n'
' "four" = 0\n'
' },\n'
' {\n'
' "one" = 0,\n'
' "two" = 0,\n'
' "three" = 0,\n'
' "four" = 0\n'
' },\n'
' {\n'
' "one" = 0,\n'
' "two" = 0,\n'
' "three" = 0,\n'
' "four" = 0\n'
' }\n'
']\n'
;
INSERT INTO t1 VALUES(0, @json_value, @json_value);
SELECT COUNT(*) FROM t1 WHERE a = @json_value;
SELECT COUNT(*) FROM t1 WHERE b = @json_value;
DROP TABLE t1;
DROP COMPRESSION_
*******
Limitations:
* 'COLUMN_FORMAT COMPRESSED' can only be specified for 'BLOB' / 'TEXT' / 'VARCHAR' / 'VARBINARY' columns (and their 'LONG' / 'MEDIUM' variants).
* Compressed columns are not allowed in the key list
* 'ALTER TABLE ... DISCARD/IMPORT TABLESPACE' is not supported for tables with compressed columns.
*******
Added two new server variables:
- innodb_
"Compression level used for compressed columns. 0 is no compression,"
"1 is fastest and 9 is best compression. Default is 6."
- innodb_
"Compress column data if its length exceeds this value. Default is 96"
*******
'mysqldump' extension:
1. By default, with no additional options, 'mysqldump' will generate 'compatible' SQL output.
All "/*!50633 COLUMN_FORMAT COMPRESSED */" and "/*!50633 COLUMN_FORMAT COMPRESSED WITH COMPRESSION_
2. When a new option '--enable-
ctionary> */" will be transformed into "/*!50633 COLUMN_FORMAT COMPRESSED */". In this mode no "CREATE/DROP COMPRESSION_
3. When a new option '--enable-
Moreover, the following dictionary creation fragments will be added before "CREATE TABLE" statements which are going to use these dictionaries for the first time.
-------
/*!50633 DROP COMPRESSION_
/*!50633 CREATE COMPRESSION_
-------
4. Two new options '--add-
l be skipped or not. By default, '--add-
5. When both '--enable-
-------
/*!50633 CREATE COMPRESSION_
-------
*******
Downgrade scenario
If it is necessary to perform Percona Server downgrade from a version >= 5.6.33 to a version <5.6.33 and user databases have one or more table with compressed columns, there are two options to do this safely:
1. Use 'mysqldump' in 'compatible' mode (no compressed columns extensions must be specified).
2. Manually remove COMPRESSED attribute from all columns which have it via
"ALTER TABLE ... MODIFY ... COLUMN_FORMAT DEFAULT" before updating server binaries.
In this case, the downgraded server can start safely with old data files.
Blueprint information
- Status:
- Complete
- Approver:
- None
- Priority:
- High
- Drafter:
- Yura Sorokin
- Direction:
- Approved
- Assignee:
- Yura Sorokin
- Definition:
- Approved
- Series goal:
- Accepted for 5.6
- Implementation:
-
Implemented
- Milestone target:
-
5.6.33-79.0
- Started by
- Yura Sorokin
- Completed by
- Yura Sorokin
Related branches
Related bugs
Sprints
Whiteboard
Work Items
Dependency tree

* Blueprints in grey have been implemented.