MartijnVisser commented on a change in pull request #18316:
URL: https://github.com/apache/flink/pull/18316#discussion_r781188418



##########
File path: docs/content.zh/docs/dev/table/config.md
##########
@@ -91,6 +91,39 @@ Flink SQL> SET 'table.exec.mini-batch.size' = '5000';
 {{< /tab >}}
 {{< /tabs >}}
 
+### Idle State Retention Time
+
+Many queries aggregate or join records on one or more key attributes. When 
such a query is executed
+on a stream, the continuous query needs to collect records or maintain partial 
results per key.
+If the key domain of the input stream is evolving, i.e., the active key values 
are changing over
+time, the continuous query accumulates more and more state as more and more 
distinct keys are
+observed. However, often keys become inactive after some time and their 
corresponding state
+becomes stale and useless.
+
+For example the following query computes the number of clicks per session.
+
+```sql
+SELECT sessionId, COUNT(*) FROM clicks GROUP BY sessionId;
+```
+
+The `sessionId` attribute is used as a grouping key and the continuous query 
maintains a count
+for each `sessionId` it observes. The `sessionId` attribute is evolving over 
time and `sessionId`
+values are only active until the session ends, i.e., for a limited period of 
time. However, the
+continuous query cannot know about this property of `sessionId` and expects 
that every `sessionId`
+value can occur at any point of time. It maintains a count for each observed 
`sessionId` value.
+Consequently, the total state size of the query is continuously growing as 
more and more `sessionId`
+values are observed.
+
+The *Idle State Retention Time* parameter [`table.exec.state.ttl`]({{< ref 
"docs/dev/table/config" >}}#table-exec-state-ttl)
+define for how long the state of a key is retained without being updated 
before it is removed.
+For the previous example query, the count of a`sessionId` would be removed as 
soon as it has not
+been updated for the configured period of time.
+
+By removing the state of a key, the continuous query completely forgets that 
it has seen this key
+before. If a record with a key, whose state has been removed before, is 
processed, the record will
+be treated as if it was the first record with the respective key. For the 
example above this means
+that the count of a `sessionId` would start again at `0`.
+

Review comment:
       @twalthr This is the re-introduction of the documentation that was 
removed, to make sure that the relevant part of 'Query Configuration' now has a 
good documentation spot again and all broken links point to this documentation 
again. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to