2021-01-21 07:26:08 +00:00
|
|
|
-- There is different code path when:
|
|
|
|
-- - _state is not requested
|
|
|
|
-- - _state is requested
|
|
|
|
-- - only _state is requested
|
|
|
|
SELECT * FROM system.parts FORMAT Null;
|
|
|
|
SELECT *, _state FROM system.parts FORMAT Null;
|
|
|
|
SELECT _state FROM system.parts FORMAT Null;
|
|
|
|
|
|
|
|
-- Create one table and see some columns in system.parts
|
|
|
|
DROP TABLE IF EXISTS data_01660;
|
|
|
|
CREATE TABLE data_01660 (key Int) Engine=MergeTree() ORDER BY key;
|
|
|
|
SYSTEM STOP MERGES data_01660;
|
|
|
|
|
|
|
|
-- Empty
|
|
|
|
SELECT _state FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|
|
|
|
SELECT name, _state FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|
|
|
|
SELECT name, active FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|
|
|
|
|
|
|
|
-- Add part and check again
|
|
|
|
SELECT '# two parts';
|
|
|
|
INSERT INTO data_01660 VALUES (0);
|
|
|
|
INSERT INTO data_01660 VALUES (1);
|
|
|
|
SELECT _state FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|
|
|
|
SELECT name, _state FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|
|
|
|
SELECT name, active FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|
|
|
|
|
|
|
|
-- OPTIMIZE to create Outdated parts
|
|
|
|
SELECT '# optimize';
|
|
|
|
SYSTEM START MERGES data_01660;
|
|
|
|
OPTIMIZE TABLE data_01660 FINAL;
|
2022-09-29 19:26:52 +00:00
|
|
|
SELECT count(), _state FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660' GROUP BY _state ORDER BY _state;
|
2021-01-21 07:26:08 +00:00
|
|
|
|
|
|
|
-- TRUNCATE does not remove parts instantly
|
2022-09-22 22:51:13 +00:00
|
|
|
-- Empty active parts are clearing by async process
|
|
|
|
-- Inactive parts are clearing by async process also
|
2021-01-21 07:26:08 +00:00
|
|
|
SELECT '# truncate';
|
|
|
|
TRUNCATE data_01660;
|
2022-09-22 22:51:13 +00:00
|
|
|
SELECT if (count() > 0, 'HAVE PARTS', 'NO PARTS'), _state FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660' GROUP BY _state;
|
2021-01-21 07:26:08 +00:00
|
|
|
|
|
|
|
-- But DROP does
|
|
|
|
SELECT '# drop';
|
|
|
|
DROP TABLE data_01660;
|
|
|
|
SELECT * FROM system.parts WHERE database = currentDatabase() AND table = 'data_01660';
|