Re: [HACKERS] Custom compression methods
Robert Haas <robertmhaas@gmail.com>
On Wed, Mar 10, 2021 at 6:52 AM Dilip Kumar <dilipbalaut@gmail.com> wrote: > The pending comment is providing a way to rewrite a table and > re-compress the data with the current compression method. I spent some time poking at this yesterday and ran couldn't figure out what was going on here. There are two places where we rewrite tables. One is the stuff in cluter.c, which handles VACUUM FULL and CLUSTER. That eventually calls reform_and_rewrite_tuple(), which deforms the old tuple and creates a new one, but it doesn't seem like there's anything in there that would expand toasted values, whether external or inline compressed. But I think that can't be right, because it seems like then you'd end up with toast pointers into the old TOAST relation, not the new one, which would cause failures later. So I must be missing something here. The other place where we rewrite tables is in ATRewriteTable() as part of the ALTER TABLE machinery. I don't see anything there to force detoasting either. That said, I think that using the word REWRITE may not really capture what we're on about. Leaving aside the question of exactly what the CLUSTER code does today, you could in theory rewrite the main table by just taking all the tuples and putting them into a new relfilenode. And then you could do the same thing with the TOAST table. And despite having fully rewritten both tables, you wouldn't have done anything that helps with this problem because you haven't deformed the tuples at any point. Now as it happens we do have code -- in reform_and_rewrite_tuple() -- that does deform and reform the tuples, but it doesn't take care of this problem either. We might need to distinguish between rewriting the table, which is mostly about getting a new relfilenode, and some other word that means doing this. But, I am not really convinced that we need to solve this problem by adding new ALTER TABLE syntax. I'd be happy enough if CLUSTER, VACUUM FULL, and versions of ALTER TABLE that already force a rewrite would cause the compression to be redone also. Honestly, even if the user had to fall back on creating a new table and doing INSERT INTO newtab SELECT * FROM oldtab I would consider that to be not a total showstopper for this .. assuming of course that it actually works. If it doesn't, we have big problems. Even without the pg_am stuff, we still need to make sure that we don't just blindly let compressed values wander around everywhere. When we insert into a table column with a compression method, we should recompress any data that is compressed using some other method. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
docs: Update TOAST storage docs for configurable compression.
- e8c435a824e1 14.0 landed
-
Further tweaking of pg_dump's handling of default_toast_compression.
- 54bb91c30e39 14.0 landed
-
Fix interaction of TOAST compression with expression indexes.
- 5db1fd7823a1 14.0 landed
-
Tidy up more loose ends related to configurable TOAST compression.
- e5595de03ec6 14.0 landed
-
Short-circuit slice requests that are for more than the object's size.
- 063dd37ebc76 14.0 landed
-
Mostly-cosmetic adjustments of TOAST-related macros.
- aeb1631ed207 14.0 landed
-
Remove useless configure probe for <lz4/lz4.h>.
- 2c75f8a612b2 14.0 landed
-
Error on invalid TOAST compression in CREATE or ALTER TABLE.
- a4d5284a10b5 14.0 landed
-
docs: Fix omissions related to configurable TOAST compression.
- 24f0e395ac58 14.0 landed
-
More code cleanup for configurable TOAST compression.
- 226e2be3876d 14.0 landed
-
Bring configure support for LZ4 up to snuff.
- 4d399a6fbeb7 14.0 landed
-
Make compression.sql regression test independent of default.
- fd1ac9a54896 14.0 landed
-
Use valid compression method in brin_form_tuple
- 882b2cdc08c4 14.0 landed
-
Fix up pg_dump's handling of per-attribute compression options.
- aa25d1089ac0 14.0 landed
-
Allow configurable LZ4 TOAST compression.
- bbe0a81db69b 14.0 landed
-
Fix inconsistencies in the code
- 6b8548964bcc 13.0 cited
-
Mostly-cosmetic improvements in memory chunk header alignment coding.
- f65d21b25808 11.0 cited
-
Allow numeric to use a more compact, 2-byte header in many cases.
- 145343534c15 9.1.0 cited