mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fixing rendering.
This commit is contained in:
parent
0270b96ffb
commit
5769822c53
@ -74,30 +74,17 @@ There isn’t a separate query for deleting views. To delete a view, use [DROP T
|
|||||||
CREATE LIVE VIEW [IF NOT EXISTS] [db.]table_name [WITH [TIMEOUT [value_in_sec] [AND]] [REFRESH [value_in_sec]]] AS SELECT ...
|
CREATE LIVE VIEW [IF NOT EXISTS] [db.]table_name [WITH [TIMEOUT [value_in_sec] [AND]] [REFRESH [value_in_sec]]] AS SELECT ...
|
||||||
```
|
```
|
||||||
|
|
||||||
Live views store result of the corresponding [SELECT](../../../sql-reference/statements/select/index.md) query
|
Live views store result of the corresponding [SELECT](../../../sql-reference/statements/select/index.md) query and are updated any time the result of the query changes. Query result as well as partial result needed to combine with new data are stored in memory providing increased performance
|
||||||
and are updated any time the result of the query changes. Query result as well as partial result
|
for repeated queries. Live views can provide push notifications when query result changes using the [WATCH](../../../sql-reference/statements/watch.md) query.
|
||||||
needed to combine with new data are stored in memory providing increased performance
|
|
||||||
for repeated queries. Live views can provide push notifications
|
|
||||||
when query result changes using the [WATCH](../../../sql-reference/statements/watch.md) query.
|
|
||||||
|
|
||||||
Live views are triggered by insert into the innermost table specified in the query.
|
Live views are triggered by insert into the innermost table specified in the query.
|
||||||
|
|
||||||
!!! info "Note"
|
Live views work similarly to how a query in a distributed table works. But instead of combining partial results from different servers they combine partial result from current data with partial result from the new data. When a live view query includes a subquery then the cached partial result is only stored for the innermost subquery.
|
||||||
[Table function](../../../sql-reference/table-functions/index.md) is not supported as the innermost table.
|
|
||||||
|
|
||||||
!!! info "Note"
|
!!! info "Note"
|
||||||
Tables that do not have inserts such as a [dictionary](../../../sql-reference/dictionaries/index.md)
|
- [Table function](../../../sql-reference/table-functions/index.md) is not supported as the innermost table.
|
||||||
or a [system table](../../../operations/system-tables/index.md)
|
- Tables that do not have inserts such as a [dictionary](../../../sql-reference/dictionaries/index.md) or a [system table](../../../operations/system-tables/index.md) will not trigger a live view. See [WITH REFRESH](#live-view-with-refresh) to enable periodic updates of a live view.
|
||||||
will not trigger a live view. See [WITH REFRESH](#live-view-with-refresh) to enable periodic
|
- Only queries where one can combine partial result from the old data plus partial result from the new data will work. Live view will not work for queries that require the complete data set to compute the final result.
|
||||||
updates of a live view.
|
|
||||||
|
|
||||||
Live views work similarly to how a query in a distributed table works. But instead of combining partial results
|
|
||||||
from different servers they combine partial result from current data with partial result from the new data.
|
|
||||||
When a live view query includes a subquery then the cached partial result is only stored for the innermost subquery.
|
|
||||||
|
|
||||||
!!! info "Note"
|
|
||||||
Only queries where one can combine partial result from the old data plus partial result from the new data will work.
|
|
||||||
Live view will not work for queries that require the complete data set to compute the final result.
|
|
||||||
|
|
||||||
You can watch for changes in the live view query result using the [WATCH](../../../sql-reference/statements/watch.md) query
|
You can watch for changes in the live view query result using the [WATCH](../../../sql-reference/statements/watch.md) query
|
||||||
|
|
||||||
@ -111,9 +98,7 @@ or add [EVENTS](../../../sql-reference/statements/watch.md#events-clause) clause
|
|||||||
WATCH [db.]live_view EVENTS
|
WATCH [db.]live_view EVENTS
|
||||||
```
|
```
|
||||||
|
|
||||||
You can execute [SELECT](../../../sql-reference/statements/select/index.md) query on a live view
|
You can execute [SELECT](../../../sql-reference/statements/select/index.md) query on a live view in the same way as for any regular view or a table. If the query result is cached it will return the result immediately without running the stored query on the underlying tables.
|
||||||
in the same way as for any regular view or a table. If the query result is cached
|
|
||||||
it will return the result immediately without running the stored query on the underlying tables.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
SELECT * FROM [db.]live_view WHERE ...
|
SELECT * FROM [db.]live_view WHERE ...
|
||||||
@ -125,9 +110,7 @@ You can force live view refresh using the `ALTER LIVE VIEW [db.]table_name REFRE
|
|||||||
|
|
||||||
### With Timeout {#live-view-with-timeout}
|
### With Timeout {#live-view-with-timeout}
|
||||||
|
|
||||||
When a live view is create with a `WITH TIMEOUT` clause then the live view will be dropped automatically after the specified
|
When a live view is create with a `WITH TIMEOUT` clause then the live view will be dropped automatically after the specified number of seconds elapse since the end of the last [WATCH](../../../sql-reference/statements/watch.md) query that was watching the live view.
|
||||||
number of seconds elapse since the end of the last [WATCH](../../../sql-reference/statements/watch.md) query
|
|
||||||
that was watching the live view.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE LIVE VIEW [db.]table_name WITH TIMEOUT [value_in_sec] AS SELECT ...
|
CREATE LIVE VIEW [db.]table_name WITH TIMEOUT [value_in_sec] AS SELECT ...
|
||||||
@ -137,8 +120,7 @@ If the timeout value is not specified then the value specified by the `temporary
|
|||||||
|
|
||||||
### With Refresh {#live-view-with-refresh}
|
### With Refresh {#live-view-with-refresh}
|
||||||
|
|
||||||
When a live view is created with a `WITH REFRESH` clause then it will be automatically refreshed
|
When a live view is created with a `WITH REFRESH` clause then it will be automatically refreshed after the specified number of seconds elapse since the last refresh or trigger.
|
||||||
after the specified number of seconds elapse since the last refresh or trigger.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE LIVE VIEW [db.]table_name WITH REFRESH [value_in_sec] AS SELECT ...
|
CREATE LIVE VIEW [db.]table_name WITH REFRESH [value_in_sec] AS SELECT ...
|
||||||
|
@ -17,9 +17,7 @@ WATCH [db.]live_view
|
|||||||
[FORMAT format]
|
[FORMAT format]
|
||||||
```
|
```
|
||||||
|
|
||||||
The `WATCH` query performs continuous data retrieval from a [live view](./create/view.md#live-view) table.
|
The `WATCH` query performs continuous data retrieval from a [live view](./create/view.md#live-view) table. Unless the `LIMIT` clause is specified it provides an infinite stream of query results from a live view.
|
||||||
Unless the `LIMIT` clause is specified it provides an infinite stream of query results
|
|
||||||
from a live view.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
WATCH [db.]live_view
|
WATCH [db.]live_view
|
||||||
@ -27,8 +25,7 @@ WATCH [db.]live_view
|
|||||||
|
|
||||||
The virtual `_version` column in the query result indicates the current result version.
|
The virtual `_version` column in the query result indicates the current result version.
|
||||||
|
|
||||||
By default, the requested data is returned to the client, while in conjunction with [INSERT INTO](../../sql-reference/statements/insert-into.md)
|
By default, the requested data is returned to the client, while in conjunction with [INSERT INTO](../../sql-reference/statements/insert-into.md) it can be forwarded to a different table.
|
||||||
it can be forwarded to a different table.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
INSERT INTO [db.]table WATCH [db.]live_view ...
|
INSERT INTO [db.]table WATCH [db.]live_view ...
|
||||||
@ -36,9 +33,7 @@ INSERT INTO [db.]table WATCH [db.]live_view ...
|
|||||||
|
|
||||||
## EVENTS Clause {#events-clause}
|
## EVENTS Clause {#events-clause}
|
||||||
|
|
||||||
The `EVENTS` clause can be used to obtain a short form of the `WATCH` query
|
The `EVENTS` clause can be used to obtain a short form of the `WATCH` query where instead of the query result you will just get the latest query result version.
|
||||||
where instead of the query result you will just get the latest query
|
|
||||||
result version.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
WATCH [db.]live_view EVENTS LIMIT 1
|
WATCH [db.]live_view EVENTS LIMIT 1
|
||||||
@ -46,14 +41,10 @@ WATCH [db.]live_view EVENTS LIMIT 1
|
|||||||
|
|
||||||
## LIMIT Clause {#limit-clause}
|
## LIMIT Clause {#limit-clause}
|
||||||
|
|
||||||
The `LIMIT n` clause species the number of updates the `WATCH` query should wait
|
The `LIMIT n` clause species the number of updates the `WATCH` query should wait for before terminating. By default there is no limit on the number of updates and therefore the query will not terminate. The value of `0` indicates that the `WATCH` query should not wait for any new query results and therefore will return immediately once query is evaluated.
|
||||||
for before terminating. By default there is no limit on the number of updates and therefore
|
|
||||||
the query will not terminate. The value of `0`
|
|
||||||
indicates that the `WATCH` query should not wait for any new query results
|
|
||||||
and therefore will return immediately once query is evaluated.
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
WATCH [db.]live_view LIMIT 1
|
WATCH [db.]live_view LIMIT 2
|
||||||
```
|
```
|
||||||
|
|
||||||
## FORMAT Clause {#format-clause}
|
## FORMAT Clause {#format-clause}
|
||||||
@ -61,8 +52,5 @@ WATCH [db.]live_view LIMIT 1
|
|||||||
The `FORMAT` clause works the same way as for the [SELECT](./select/index.md#format-clause).
|
The `FORMAT` clause works the same way as for the [SELECT](./select/index.md#format-clause).
|
||||||
|
|
||||||
!!! info "Note"
|
!!! info "Note"
|
||||||
The [JSONEachRowWithProgress](../../interfaces/formats/#jsoneachrowwithprogress) format should be used when watching [live view](./create/view.md#live-view)
|
The [JSONEachRowWithProgress](../../interfaces/formats/#jsoneachrowwithprogress) format should be used when watching [live view](./create/view.md#live-view) tables over the HTTP interface. The progress messages will be added to the output to keep the long-lived HTTP connection alive until the query result changes. The interval between progress messages is controlled using the [live_view_heartbeat_interval](./create/view.md#live-view-settings) setting.
|
||||||
tables over the HTTP interface. The progress messages will be added to the output
|
|
||||||
to keep the long-lived HTTP connection alive until the query result changes.
|
|
||||||
The interval between progress messages is controlled using the [live_view_heartbeat_interval](./create/view.md#live-view-settings) setting.
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user