Re: [HACKERS] Custom compression methods
Dilip Kumar <dilipbalaut@gmail.com>
On Thu, Feb 11, 2021 at 3:26 AM Robert Haas <robertmhaas@gmail.com> wrote: > > In CompareCompressionMethodAndDecompress, I think this is still > playing a bit fast and loose with the rules around slots. I think we > can do better. Suppose that at the point where we discover that we > need to decompress at least one attribute, we create the new slot > right then, and also memcpy tts_values and tts_isnull. Then, for that > attribute and any future attributes that need decompression, we reset > tts_values in the *new* slot, leaving the old one untouched. Then, > after finishing all the attributes, the if (decompressed_any) block, > you just have a lot less stuff to do. The advantage of this is that > you haven't tainted the old slot; it's still got whatever contents it > had before, and is in a clean state, which seems better to me. Fixed > > It's unclear to me whether this function actually needs to > ExecMaterializeSlot(newslot). It definitely does need to > ExecStoreVirtualTuple(newslot) and I think it's a very good idea, if > not absolutely mandatory, for it not to modify anything about the old > slot. But what's the argument that the new slot needs to be > materialized at this point? It may be needed, if the old slot would've > had to be materialized at this point. But it's something to think > about. I think if the original slot was materialized then materialing the new slot make more sense to me so done that way. > > The CREATE TABLE documentation says that COMPRESSION is a kind of > column constraint, but that's wrong. For example, you can't write > CREATE TABLE a (b int4 CONSTRAINT thunk COMPRESSION lz4), for example, > contrary to what the syntax summary implies. When you fix this so that > the documentation matches the grammar change, you may also need to > move the longer description further up in create_table.sgml so the > order matches. Fixed > The use of VARHDRSZ_COMPRESS in toast_get_compression_oid() appears to > be incorrect. VARHDRSZ_COMPRESS is offsetof(varattrib_4b, > va_compressed.va_data). But what gets externalized in the case of a > compressed datum is just VARDATA(dval), which excludes the length > word, unlike VARHDRSZ_COMPRESS, which does not. This has no > consequences since we're only going to fetch 1 chunk either way, but I > think we should make it correct. Fixed > TOAST_COMPRESS_SET_SIZE_AND_METHOD() could Assert something about cm_method. While replying to the comments, I realised that I have missed it. I will fix it in the next version. > Small delta patch with a few other suggested changes attached. Merged -- Regards, Dilip Kumar EnterpriseDB: 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