Clickhouse查询语句 sample

注意:

sample子句只能用于MergeTree系列引擎的数据表,并且在create table的时候就声明sample by 抽样表达式。

概述:

sample子句提供了近似计算的功能,能够实现数据采样的功能,使查询仅仅返回采样数据而不是全部数据,从而有效减少查询负载。

sample子句的采样设计是一种幂等设计,即在数据发生变化的时候使用相同的采样规则能返回相同的数据。这种特性非常适合那些可以接受近似查询结果的场景。

官方提供了如下的使用场景:

1.When you have strict timing requirements (like \<100ms) but you can’t justify the cost of additional hardware
 resources to meet them.
2.When your raw data is not accurate, so approximation doesn’t noticeably degrade the quality.
3.Business requirements target approximate results (for cost-effectiveness, or to market exact results to 
premium users).

 

你可能感兴趣的:(Clickhouse)