ClickHouse / ClickHouse/ClickHouse
Projection parts ignore `RECOMPRESS` TTL codec and are always written with the default codec
- Dominant language
- C++
- Stars
- 49.9k
- Forks
- 9k
- Avg merge
- 21h 32m
- Merged PRs (30d)
- 515
Description
Projection parts are always compressed with the table's default codec, even when a `RECOMPRESS` TTL pins the parent part to a specific codec. A `RECOMPRESS CODEC(NONE)` recompresses the main part's columns but leaves the projection's columns compressed.
### How to reproduce
```sql
CREATE TABLE t (d Date, x UInt64, PROJECTION p (SELECT x ORDER BY x))
ENGINE = MergeTree ORDER BY tuple()
TTL d + INTERVAL 1 DAY RECOMPRESS CODEC(NONE)
SETTINGS min_bytes_for_wide_part = 0;
-- d is in 2020, so the recompress boundary (2020-01-02) is already in the past:
-- OPTIMIZE FINAL recompresses now, no waiting.
INSERT INTO t SELECT '2020-01-01', number FROM numbers(100000);
OPTIMIZE TABLE t FINAL;
SELECT 'table' AS src, column,
round(column_data_compressed_bytes / column_data_uncompressed_bytes, 3) AS ratio
FROM system.parts_columns
WHERE table = 't' AND active AND column = 'x'
UNION ALL
SELECT 'projection', column,
round(column_data_compressed_bytes / column_data_uncompressed_bytes, 3)
FROM system.projection_parts_columns
WHERE table = 't' AND active AND column = 'x';
```
### Expected
```
┌─src────────┬─column─┬─ratio─┐
│ table │ x │ 1 │
│ projection │ x │ 1 │
└────────────┴────────┴───────┘
```
### Actual
```
┌─src────────┬─column─┬─ratio─┐
│ projection │ x │ 0.501 │ -- still compressed: ignored RECOMPRESS CODEC(NONE)
│ table │ x │ 1 │ -- NONE applied (uncompressed)
└────────────┴────────┴───────┘
```
Contributor guide
Research direction
Start by running the SQL reproduction with the projection, RECOMPRESS CODEC(NONE), and OPTIMIZE TABLE t FINAL, then compare system.parts_columns with system.projection_parts_columns. Trace the recompression path for the main part and its projection; done means both reported compression ratios are 1, showing that the projection also uses CODEC(NONE).
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100