ClickHouse 使用

CREATE DATABASE test on cluster ck_00_1repl;

DROP TABLE local_t_ordt_order on cluster ck_00_1repl;

创建本地 local 表

CREATE TABLE test.local_order_db_t_order on cluster ck_00_1repl

(
forder_id_hash String,
forder_id String,
fuid Int32,
forder_type Int32,
fsale_type Int32,
frepay_type Int32,
forder_info String,
ftotal_amount Int64,
ftotal_handling_fee Int32,
ftotal_mon_pay Int32,
fextra_capital Int32,
ftotal_manage_fee Int64,
fversion Int32,
fpay_way Int32,
fpay_suc_time DateTime,
fetl_time DateTime,
forder_state Date,
f_p_date Date

)

ENGINE = ReplicatedMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')

PARTITION BY f_p_date

PRIMARY KEY (forder_type, fsale_type, forder_state)

ORDER BY (forder_type, fsale_type, forder_state, forder_id)

TTL f_p_date+ toIntervalDay(7)

SETTINGS index_granularity = 8192;

创建分布式 distributed 表

CREATE TABLE test.t_order_db_t_order on cluster ck_00_1repl

(
forder_id_hash String,
forder_id String,
fuid Int32,
forder_type Int32,
fsale_type Int32,
frepay_type Int32,
forder_info String,
ftotal_amount Int64,
ftotal_handling_fee Int32,
ftotal_mon_pay Int32,
fextra_capital Int32,
ftotal_manage_fee Int64,
fversion Int32,
fpay_way Int32,
fpay_suc_time DateTime,
fetl_time DateTime,
forder_state Date,
f_p_date Date

)

ENGINE = Distributed('ck_00_1repl', 'test', 'local_order_db_t_order', rand());

SHOW DATABASES;

SHOW TABLES;

INSERT INTO test.local_order_db_t_order(forder_id) VALUES ('1_10.9.104.249');

INSERT INTO test.local_order_db_t_order(forder_id) VALUES ('2_10.9.104.250');

select * from test.local_order_db_t_order;

select count(1) from test.local_order_db_t_order;

select * from test.t_order_db_t_order;

select count(1) from test.t_order_db_t_order;

数据量记录

1、实时数据仓库

4百亿+
4十亿+

2、日志


5.5万亿+
2.9千亿+

相关推荐
狂奔solar1 小时前
Vanna + qwq32b 实现 text2SQL
数据库·sql
网络安全工程师老王1 小时前
clickhouse注入手法总结
数据库·clickhouse·web安全·网络安全·信息安全
OceanBase数据库官方博客5 小时前
火山模型的优缺点与优化实践 | OceanBase SQL优化
sql·oceanbase·分布式数据库
Dav_209911 小时前
dav_1_MySQL数据库排查cpu消耗高的sql
数据库·sql·mysql
小诸葛的博客13 小时前
Go 语言中的select是做什么的
数据库·sql·golang
Gauss松鼠会14 小时前
GaussDB Plan Hint调优实战:从执行计划控制到性能优化
数据库·sql·性能优化·database·gaussdb
程序辕日记15 小时前
使用SQL查询ES数据
sql·elasticsearch·jenkins
zeijiershuai15 小时前
MySQL-SQL-DQL语句、DQL基本查询、DQL条件查询、DQL分组查询、聚合函数、DQL排序查询、DQL分页查询
数据库·sql·mysql
喵喵帕斯16 小时前
MySQL索引优化-show index
后端·sql·mysql
喵喵帕斯19 小时前
MySQL索引优化-索引可见性
后端·sql·mysql