M
и поймите в какой момент и как именно производится суммирование
Size: a a a
M
S
M
CREATE TABLE my_table (
`name` String,
`id` UInt64,
`amount` Int64,
`currency` String,
`created_at` DateTime
) ENGINE = ReplicatedSummingMergeTree(...)
ORDER BY
(
name,
id,
created_at,
currency
)
M
AB
M
S
M
S
M
AA
SYSTEM SYNC REPLICA default.test_sync
Received exception from server (version 20.8.12):
Code: 236. DB::Exception: Received from localhost:9000. DB::Exception: Log pulling is cancelled.
0 rows in set. Elapsed: 0.002 sec.
M
CREATE TABLE test
(
user_id UInt64,
amount Int64
)
ENGINE = SummingMergeTree()
ORDER BY (user_id)
select uniqExact(user_id) from my_table => 70k
insert into test (user_id, amount) select user_id, amount from my_table
select uniqExact(user_id) from test => 60k
M
CREATE TABLE test
(
user_id UInt64,
amount Int64
)
ENGINE = SummingMergeTree()
ORDER BY (user_id)
select uniqExact(user_id) from my_table => 70k
insert into test (user_id, amount) select user_id, amount from my_table
select uniqExact(user_id) from test => 60k
Если значения во всех столбцах для суммирования оказались нулевыми, то строчка удаляется.
M
CREATE TABLE summtt
(
`key` UInt32,
`value` UInt32
)
ENGINE = SummingMergeTree()
ORDER BY key
INSERT INTO summtt Values(1,1),(1,2),(2,1),(3,0)
SELECT *
FROM summtt
FINAL
┌─key─┬─value─┐
│ 1 │ 3 │
│ 2 │ 1 │
└─────┴───────┘
IK
D
ENGINE = MergeTree()
M
ENGINE = MergeTree()
D
M
M