mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-16 03:12:43 +00:00
2e85f9f0ad
Previously all WAL files had been stored, though with the time of use this can take too much space on disk, and also the startup time will be increased. But it is pretty easy to prune old WAL files (the one parts from which had been completely written to disk already). Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
28 lines
1.0 KiB
SQL
28 lines
1.0 KiB
SQL
-- { echo }
|
|
|
|
DROP TABLE IF EXISTS in_memory;
|
|
|
|
CREATE TABLE in_memory (a UInt32) ENGINE = MergeTree ORDER BY a SETTINGS min_rows_for_compact_part = 1000, min_bytes_for_wide_part = 10485760;
|
|
INSERT INTO in_memory VALUES (1);
|
|
INSERT INTO in_memory VALUES (2);
|
|
SELECT name, active, part_type FROM system.parts WHERE database = currentDatabase() AND table = 'in_memory';
|
|
SELECT * FROM in_memory ORDER BY a;
|
|
|
|
-- no WAL remove since parts are still in use
|
|
DETACH TABLE in_memory;
|
|
ATTACH TABLE in_memory;
|
|
SELECT name, active, part_type FROM system.parts WHERE database = currentDatabase() AND table = 'in_memory';
|
|
SELECT * FROM in_memory ORDER BY a;
|
|
|
|
-- WAL should be removed, since on disk part covers all parts in WAL
|
|
OPTIMIZE TABLE in_memory;
|
|
DETACH TABLE in_memory;
|
|
ATTACH TABLE in_memory;
|
|
SELECT name, active, part_type FROM system.parts WHERE database = currentDatabase() AND table = 'in_memory';
|
|
|
|
-- check that the WAL will be reinitialized after remove
|
|
INSERT INTO in_memory VALUES (3);
|
|
DETACH TABLE in_memory;
|
|
ATTACH TABLE in_memory;
|
|
SELECT * FROM in_memory ORDER BY a;
|