forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbbe0a81
committed
Allow configurable LZ4 TOAST compression.
There is now a per-column COMPRESSION option which can be set to pglz(the default, and the only option in up until now) or lz4. Or, if youlike, you can set the new default_toast_compression GUC to lz4, andthen that will be the default for new table columns for which no valueis specified. We don't have lz4 support in the PostgreSQL code, soto use lz4 compression, PostgreSQL must be built --with-lz4.In general, TOAST compression means compression of individual columnvalues, not the whole tuple, and those values can either be compressedinline within the tuple or compressed and then stored externally inthe TOAST table, so those properties also apply to this feature.Prior to this commit, a TOAST pointer has two unused bits as part ofthe va_extsize field, and a compessed datum has two unused bits aspart of the va_rawsize field. These bits are unused because the lengthof a varlena is limited to 1GB; we now use them to indicate thecompression type that was used. This means we only have bit space for2 more built-in compresison types, but we could work around thatproblem, if necessary, by introducing a new vartag_external value forany further types we end up wanting to add. Hopefully, it won't betoo important to offer a wide selection of algorithms here, sinceeach one we add not only takes more coding but also adds a builddependency for every packager. Nevertheless, it seems worth doingat least this much, because LZ4 gets better compression than PGLZwith less CPU usage.It's possible for LZ4-compressed datums to leak into composite typevalues stored on disk, just as it is for PGLZ. It's also possible forLZ4-compressed attributes to be copied into a different table via SQLcommands such as CREATE TABLE AS or INSERT .. SELECT. It would beexpensive to force such values to be decompressed, so PostgreSQL hasnever done so. For the same reasons, we also don't force recompressionof already-compressed values even if the target table prefers adifferent compression method than was used for the source data. Thesearchitectural decisions are perhaps arguable but revisiting them iswell beyond the scope of what seemed possible to do as part of thisproject. However, it's relatively cheap to recompress as part ofVACUUM FULL or CLUSTER, so this commit adjusts those commands to doso, if the configured compression method of the table happens not tomatch what was used for some column value stored therein.Dilip Kumar. The original patches on which this work was based werewritten by Ildus Kurbangaliev, and those were patches were based oneven earlier work by Nikita Glukhov, but the design has since changedvery substantially, since allow a potentially large number ofcompression methods that could be added and dropped on a runningsystem proved too problematic given some of the architectural issuesmentioned above; the choice of which specific compression method toadd first is now different; and a lot of the code has been heavilyrefactored. More recently, Justin Przyby helped quite a bit withtesting and reviewing and this version also includes some codecontributions from him. Other design input and review from TomasVondra, Álvaro Herrera, Andres Freund, Oleg Bartunov, AlexanderKorotkov, and me.Discussion:http://postgr.es/m/20170907194236.4cefce96%40wp.localdomainDiscussion:http://postgr.es/m/CAFiTN-uUpX3ck%3DK0mLEk-G_kUQY%3DSNOTeqdaNRR9FMdQrHKebw%40mail.gmail.com1 parente589c48 commitbbe0a81
File tree
61 files changed
+2261
-160
lines changed- contrib/amcheck
- doc/src/sgml
- ref
- src
- backend
- access
- brin
- common
- heap
- table
- bootstrap
- catalog
- commands
- nodes
- parser
- replication/logical
- utils
- adt
- misc
- bin
- pg_amcheck/t
- pg_dump
- t
- psql
- include
- access
- catalog
- nodes
- parser
- test/regress
- expected
- sql
- tools/msvc
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
61 files changed
+2261
-160
lines changedLines changed: 170 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
699 | 699 |
| |
700 | 700 |
| |
701 | 701 |
| |
| 702 | + | |
| 703 | + | |
| 704 | + | |
702 | 705 |
| |
703 | 706 |
| |
704 | 707 |
| |
| |||
864 | 867 |
| |
865 | 868 |
| |
866 | 869 |
| |
| 870 | + | |
867 | 871 |
| |
868 | 872 |
| |
869 | 873 |
| |
| |||
891 | 895 |
| |
892 | 896 |
| |
893 | 897 |
| |
| 898 | + | |
| 899 | + | |
894 | 900 |
| |
895 | 901 |
| |
896 | 902 |
| |
| |||
1569 | 1575 |
| |
1570 | 1576 |
| |
1571 | 1577 |
| |
| 1578 | + | |
1572 | 1579 |
| |
1573 | 1580 |
| |
1574 | 1581 |
| |
| |||
1596 | 1603 |
| |
1597 | 1604 |
| |
1598 | 1605 |
| |
| 1606 | + | |
| 1607 | + | |
1599 | 1608 |
| |
1600 | 1609 |
| |
1601 | 1610 |
| |
| |||
8563 | 8572 |
| |
8564 | 8573 |
| |
8565 | 8574 |
| |
| 8575 | + | |
| 8576 | + | |
| 8577 | + | |
| 8578 | + | |
| 8579 | + | |
| 8580 | + | |
| 8581 | + | |
| 8582 | + | |
| 8583 | + | |
| 8584 | + | |
| 8585 | + | |
| 8586 | + | |
| 8587 | + | |
| 8588 | + | |
| 8589 | + | |
| 8590 | + | |
| 8591 | + | |
| 8592 | + | |
| 8593 | + | |
| 8594 | + | |
| 8595 | + | |
| 8596 | + | |
| 8597 | + | |
| 8598 | + | |
| 8599 | + | |
| 8600 | + | |
| 8601 | + | |
| 8602 | + | |
| 8603 | + | |
| 8604 | + | |
| 8605 | + | |
| 8606 | + | |
| 8607 | + | |
| 8608 | + | |
| 8609 | + | |
| 8610 | + | |
| 8611 | + | |
| 8612 | + | |
| 8613 | + | |
| 8614 | + | |
| 8615 | + | |
| 8616 | + | |
| 8617 | + | |
| 8618 | + | |
| 8619 | + | |
| 8620 | + | |
| 8621 | + | |
| 8622 | + | |
| 8623 | + | |
| 8624 | + | |
| 8625 | + | |
| 8626 | + | |
| 8627 | + | |
| 8628 | + | |
| 8629 | + | |
| 8630 | + | |
| 8631 | + | |
| 8632 | + | |
| 8633 | + | |
| 8634 | + | |
| 8635 | + | |
| 8636 | + | |
| 8637 | + | |
| 8638 | + | |
| 8639 | + | |
| 8640 | + | |
| 8641 | + | |
| 8642 | + | |
| 8643 | + | |
| 8644 | + | |
| 8645 | + | |
| 8646 | + | |
| 8647 | + | |
| 8648 | + | |
| 8649 | + | |
| 8650 | + | |
| 8651 | + | |
| 8652 | + | |
| 8653 | + | |
| 8654 | + | |
| 8655 | + | |
| 8656 | + | |
| 8657 | + | |
| 8658 | + | |
| 8659 | + | |
| 8660 | + | |
| 8661 | + | |
| 8662 | + | |
| 8663 | + | |
| 8664 | + | |
| 8665 | + | |
| 8666 | + | |
| 8667 | + | |
| 8668 | + | |
| 8669 | + | |
| 8670 | + | |
| 8671 | + | |
| 8672 | + | |
| 8673 | + | |
| 8674 | + | |
| 8675 | + | |
| 8676 | + | |
| 8677 | + | |
| 8678 | + | |
| 8679 | + | |
| 8680 | + | |
| 8681 | + | |
| 8682 | + | |
| 8683 | + | |
| 8684 | + | |
| 8685 | + | |
| 8686 | + | |
| 8687 | + | |
| 8688 | + | |
| 8689 | + | |
| 8690 | + | |
| 8691 | + | |
| 8692 | + | |
| 8693 | + | |
| 8694 | + | |
| 8695 | + | |
| 8696 | + | |
| 8697 | + | |
| 8698 | + | |
| 8699 | + | |
| 8700 | + | |
| 8701 | + | |
| 8702 | + | |
| 8703 | + | |
| 8704 | + | |
| 8705 | + | |
8566 | 8706 |
| |
8567 | 8707 |
| |
8568 | 8708 |
| |
| |||
13379 | 13519 |
| |
13380 | 13520 |
| |
13381 | 13521 |
| |
| 13522 | + | |
| 13523 | + | |
| 13524 | + | |
| 13525 | + | |
| 13526 | + | |
| 13527 | + | |
| 13528 | + | |
| 13529 | + | |
| 13530 | + | |
| 13531 | + | |
| 13532 | + | |
| 13533 | + | |
| 13534 | + | |
| 13535 | + | |
| 13536 | + | |
| 13537 | + | |
| 13538 | + | |
| 13539 | + | |
| 13540 | + | |
| 13541 | + | |
| 13542 | + | |
| 13543 | + | |
| 13544 | + | |
| 13545 | + | |
| 13546 | + | |
| 13547 | + | |
| 13548 | + | |
| 13549 | + | |
| 13550 | + | |
| 13551 | + | |
13382 | 13552 |
| |
13383 | 13553 |
| |
13384 | 13554 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
986 | 986 |
| |
987 | 987 |
| |
988 | 988 |
| |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
989 | 1004 |
| |
990 | 1005 |
| |
991 | 1006 |
| |
| |||
1410 | 1425 |
| |
1411 | 1426 |
| |
1412 | 1427 |
| |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
1413 | 1433 |
| |
1414 | 1434 |
| |
1415 | 1435 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1069 | 1069 |
| |
1070 | 1070 |
| |
1071 | 1071 |
| |
1072 |
| - | |
| 1072 | + | |
1073 | 1073 |
| |
1074 | 1074 |
| |
1075 | 1075 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1355 | 1355 |
| |
1356 | 1356 |
| |
1357 | 1357 |
| |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
1358 | 1370 |
| |
1359 | 1371 |
| |
1360 | 1372 |
| |
|
Lines changed: 16 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25992 | 25992 |
| |
25993 | 25993 |
| |
25994 | 25994 |
| |
25995 |
| - | |
25996 |
| - | |
| 25995 | + | |
| 25996 | + | |
25997 | 25997 |
| |
25998 | 25998 |
| |
25999 | 25999 |
| |
| |||
26028 | 26028 |
| |
26029 | 26029 |
| |
26030 | 26030 |
| |
| 26031 | + | |
| 26032 | + | |
| 26033 | + | |
| 26034 | + | |
| 26035 | + | |
| 26036 | + | |
| 26037 | + | |
| 26038 | + | |
| 26039 | + | |
| 26040 | + | |
| 26041 | + | |
| 26042 | + | |
| 26043 | + | |
| 26044 | + | |
26031 | 26045 |
| |
26032 | 26046 |
| |
26033 | 26047 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
57 | 58 |
| |
58 | 59 |
| |
59 | 60 |
| |
| |||
103 | 104 |
| |
104 | 105 |
| |
105 | 106 |
| |
| 107 | + | |
106 | 108 |
| |
107 | 109 |
| |
108 | 110 |
| |
| |||
383 | 385 |
| |
384 | 386 |
| |
385 | 387 |
| |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
386 | 402 |
| |
387 | 403 |
| |
388 | 404 |
| |
|
0 commit comments
Comments
(0)