国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Go 大數(shù)據(jù)生態(tài)開源項(xiàng)目 CDS 中 ClickHouse 使用的建表方案

實(shí)時(shí)表

從中可以看出兩點(diǎn):

  • 也就是說數(shù)據(jù)導(dǎo)入后不考慮變更,而且想要直接分析源數(shù)據(jù)。

因?yàn)樯厦嫣岬降男枨?,更新這個(gè)功能在隨后還是以 mutation 的形式加入了。這種 mutation 形式在官網(wǎng)中:

“Data deduplication occurs only during a merge. Merging occurs in the background at an unknown time, so you can't plan for it. Some of the data may remain unprocessed. Although you can run an unscheduled merge using the OPTIMIZE query, don't count on using it, because the OPTIMIZE query will read and write a large amount of data. Thus, ReplacingMergeTree is suitable for clearing out duplicate data in the background in order to save space, but it doesn't guarantee the absence of duplicates.”

final 關(guān)鍵字就可以得到最終數(shù)據(jù),而不用動(dòng)用 final 也有缺點(diǎn),就是會(huì)導(dǎo)致 MaterializeMySQL也使用了同樣的方法 https://github.com/ClickHouse/ClickHouse/issues/4006 。加上如何合理使用 利用 ClickHouse ,數(shù)據(jù)就可以被自動(dòng)合并了。

ReplacingMergeTree 合并后會(huì)變成這一列,查詢時(shí)在 where 中添加過濾條件就好了。

)

中的rtu變更insert` 的操作。

ReplacingMergeTree 具體建表方式如下:

CREATE TABLE [IF NOT EXISTS] [db.]table_name [ON CLUSTER cluster]
(
name1 [type1] [DEFAULT|MATERIALIZED|ALIAS expr1],
name2 [type2] [DEFAULT|MATERIALIZED|ALIAS expr2],
...
) ENGINE = ReplacingMergeTree([ver])
[PARTITION BY expr]
[ORDER BY expr]
[SAMPLE BY expr]
[SETTINGS name=value, ...]
  • 你需要指定一個(gè)版本列用于數(shù)據(jù)合并時(shí)確定最新數(shù)據(jù),一般指定成 ClickHouse 推薦數(shù)據(jù)直接插入 clickhosue 集群節(jié)點(diǎn)的本地存儲(chǔ)表中,而不是通過分布式表插入。這意味著你需要將數(shù)據(jù)按主鍵自行散列好后插入對(duì)應(yīng)集群節(jié)點(diǎn)的本地存儲(chǔ)表。

  • 這種表引擎對(duì) MergeTree 表中。

  • 這種表引擎給 歷史版本與還原

    如果只保存增量和變更數(shù)據(jù)將會(huì)節(jié)省很多空間,問題是如何從一堆增量和變更數(shù)據(jù)中還原每一天的數(shù)據(jù)?

    ReplacingMergeTree

     表引擎,在上面提到的第 4 點(diǎn)在 clickhouse 中使用普通 argMax和 合理的分區(qū) 方案可以實(shí)現(xiàn)版本還原。如:
    -- 查詢某一日全部用戶中編輯角色的數(shù)量
    SELECT date
    , uniq(user_id)
    FROM (
    SELECT date
    , id user_id
    , argMax(users.role, users.update_time) role_
    FROM (
    SELECT id
    , update_time
    , role
    , toDate('2020-11-11') date
    FROM default.user
    WHERE
    create_time < toDateTime(date + INTERVAL 1 DAY)
    AND update_time < toDateTime(date + INTERVAL 1 DAY)
    ) users
    GROUP BY date, id
    ) day_snap_shot -- 生成當(dāng)日快照
    WHERE role_ = 'editor'
    GROUP BY date;

    上面介紹了兩種建表方案,一種實(shí)時(shí)的,一種帶有所有版本變更的。兩種方案各有優(yōu)劣,根據(jù)使用場(chǎng)景選擇。這兩種方案都不完美。

項(xiàng)目地址

go-zero 項(xiàng)目地址:https://github.com/tal-tech/go-zero 

<p style="box-sizing: border-box;outline-style: none;margin-bottom: 20px;font-size: 15px;line-height: 26px;color: rgb(64, 64, 64);font-family: Helvetica, Arial, " pingfang="" sc",="" "noto="" sans",="" roboto,="" "microsoft="" yahei",="" sans-serif;letter-spacing:="" 0.45px;text-align:="" left;white-space:="" normal;background-color:="" rgb(255,="" 255,="" 255); 

本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ClickHouse常用命令,基本數(shù)據(jù)類型
Clickhouse 入門
數(shù)倉(cāng)引入ClickHouse之后,性能提升了400%!
趣頭條基于ClickHouse玩轉(zhuǎn)每天1000億數(shù)據(jù)量
牛!一個(gè)比傳統(tǒng)數(shù)據(jù)庫(kù)快 100-1000 倍的數(shù)據(jù)庫(kù)
ClickHouse特性及底層存儲(chǔ)原理
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服