Skip to content

Instantly share code, notes, and snippets.

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

create database and table

CREATE DATABASE demo

CREATE TABLE demo.summt
(
    key UInt32,
    value UInt32
)
ENGINE = SummingMergeTree()
ORDER BY key

insert data

INSERT INTO demo.summt
VALUES (1,1),(1,2),(2,1)

view all inserted data as is

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

force optimize

OPTIMIZE TABLE demo.summt FINAL

view data again

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