Skip to content

Instantly share code, notes, and snippets.

@kymtwyf
Created January 7, 2021 05:49
Show Gist options
  • Save kymtwyf/eb86560f8909a652d558d08985b08056 to your computer and use it in GitHub Desktop.
Save kymtwyf/eb86560f8909a652d558d08985b08056 to your computer and use it in GitHub Desktop.

create table

CREATE TABLE demo.replacemt (
  key UInt32, 
  value UInt32
)
ENGINE = ReplacingMergeTree
ORDER BY key

insert data

INSERT INTO demo.replacemt values(1,1),(1,2),(2,1)

query data immediately

SELECT * FROM demo.replacemt
key value
1 1
1 2
2 1

force optimizing

OPTIMIZE TABLE demo.replacemt FINAL

query data again

SELECT * FROM demo.replacemt
key value
1 2
2 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment