Re: [HACKERS] Custom compression methods
Robert Haas <robertmhaas@gmail.com>
On Wed, Dec 6, 2017 at 10:07 AM, Ildus Kurbangaliev <i.kurbangaliev@postgrespro.ru> wrote: > On Fri, 1 Dec 2017 21:47:43 +0100 > Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote: >> +1 to do the rewrite, just like for other similar ALTER TABLE commands > > Ok. What about the following syntax: > > ALTER COLUMN DROP COMPRESSION - removes compression from the column > with the rewrite and removes related compression options, so the user > can drop compression method. > > ALTER COLUMN SET COMPRESSION NONE for the cases when > the users want to just disable compression for future tuples. After > that they can keep compressed tuples, or in the case when they have a > large table they can decompress tuples partially using e.g. UPDATE, > and then use ALTER COLUMN DROP COMPRESSION which will be much faster > then. > > ALTER COLUMN SET COMPRESSION <cm> WITH <cmoptions> will change > compression for new tuples but will not touch old ones. If the users > want the recompression they can use DROP/SET COMPRESSION combination. > > I don't think that SET COMPRESSION with the rewrite of the whole table > will be useful enough on any somewhat big tables and same time big > tables is where the user needs compression the most. > > I understand that ALTER with the rewrite sounds logical and much easier > to implement (and it doesn't require Oids in tuples), but it could be > unusable. The problem with this is that old compression methods can still be floating around in the table even after you have done SET COMPRESSION to something else. The table still needs to have a dependency on the old compression method, because otherwise you might think it's safe to drop the old one when it really is not. Furthermore, if you do a pg_upgrade, you've got to preserve that dependency, which means it would have to show up in a pg_dump --binary-upgrade someplace. It's not obvious how any of that would work with this syntax. Maybe a better idea is ALTER COLUMN SET COMPRESSION x1, x2, x3 ... meaning that x1 is the default for new tuples but x2, x3, etc. are still allowed if present. If you issue a command that only adds things to the list, no table rewrite happens, but if you remove anything, then it does. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
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