5

I've read DuckDB Lightweight Compression and understand that DuckDB is designed to choose the best compression strategy automatically, but would like to know if it is possible to give hints in CREATE TABLE or ALTER TABLE statements to explicitly set the compression.

I didn't see anything in the CREATE TABLE Syntax documentation either.

This github issue comment (copied below) implies that it is possible.

The system itself will automatically choose the best compression option available. Overriding the automatic compression detection and choosing a compression option manually should really only be used for debugging/profiling purposes or in edge cases when the system makes one choice (e.g. best compression ratio) but you want another (e.g. best performance).

1
  • Did you get an answer @Danny G? Commented May 3, 2024 at 14:44

2 Answers 2

2

The compression can be specified per column using the USING COMPRESSION syntax:

CREATE TABLE my_table(my_col INTEGER USING COMPRESSION bitpacking);
Sign up to request clarification or add additional context in comments.

1 Comment

What are the allowed values?
1

I've tried to use this

PRAGMA force_compression='bitpacking';

from duckdb sources: https://github.com/duckdb/duckdb/blob/main/benchmark/micro/compression/bitpacking/bitpacking_read_dfor.benchmark

It indeed changes the selected compression on some columns, but not actually forces it everywhere.

Options can be any of: Auto, Uncompressed, Constant, RLE, Dictionary, PFOR, BitPacking, FSST, Chimp, Patas, ALP, ALPRD.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.