简体   繁体   English

KSQL 窗口化查询的工作原理和最大窗口大小

[英]How KSQL Windowed query works and maximum window size

I have two questions regarding querying in KSQL wrt queries that use windowing :我有两个关于在使用窗口的 KSQL wrt 查询中查询的问题:

  1. Let's say I have the following aggregation query :假设我有以下聚合查询:

    SELECT id, COUNT(*) FROM testtopic_stream WINDOW TUMBLING (SIZE 30 DAYS) GROUP BY id; SELECT id, COUNT(*) FROM testtopic_stream WINDOW TUMBLING (SIZE 30 DAYS) GROUP BY id;

Are the results of the aggregation above calculated by only using the new tick that comes in OR it actually will go through all the data for last 30 days and then perform the aggregation?上面聚合的结果是仅使用进来的新刻度计算的还是它实际上会遍历过去 30 天的所有数据然后执行聚合?

  1. What is the maximum possible window size for queries?查询的最大可能窗口大小是多少? I see I am able to set up a window for even like 30 days and the query seems to work fine now.我看到我可以设置一个窗口甚至 30 天,并且查询现在似乎可以正常工作。 Is there a recommended maximum window size?是否有推荐的最大窗口大小?

It depends on auto.offset.reset strategy.这取决于auto.offset.reset策略。 If you set it to "earliest" , the query will consumer all data from the underlying stream/topic (note, that "all" means really all data that is stored in the topic, ie, it depends on topic retention setting how much data this will be).如果您将其设置为"earliest" ,则查询将使用来自底层流/主题的所有数据(请注意,“全部”实际上意味着存储在主题中的所有数据,即,这取决于主题保留设置多少数据这将会)。 If you set the config to "latest" -- what is the default -- the query will only process data that is written by upstream producers after the query was started.如果您将配置设置为"latest" ——默认值是什么——查询将仅处理在查询开始后由上游生产者写入的数据。

In both cases, the size of the window has no impact on what data will be processed.在这两种情况下,窗口的大小对将要处理的数据没有影响。

There is no limit on the window size.窗口大小没有限制。 You can pick any size you want.你可以选择任何你想要的尺寸。 Note: for tumbling windows, a smaller window size in fact increases storage requirement while a larger window sizes reduces storage requirement because there are fewer windows that need to be maintained in parallel.注意:对于滚动窗口,较小的窗口大小实际上会增加存储需求,而较大的窗口大小会降低存储需求,因为需要并行维护的窗口较少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM