Skip to content

Commit 33dd8ec

Browse files
committed
mvs images
1 parent f3e7a11 commit 33dd8ec

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

docs/materialized-view/incremental-materialized-view.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ keywords: [incremental materialized views, speed up queries, query optimization]
66
score: 10000
77
---
88

9+
import materializedViewDiagram from '@site/static/images/materialized-view/materialized-view-diagram.png';
10+
911
# Incremental Materialized Views
1012

1113
Incremental Materialized Views (Materialized Views) allow users to shift the cost of computation from query time to insert time, resulting in faster `SELECT` queries.
@@ -16,11 +18,10 @@ The principal motivation for materialized views is that the results inserted int
1618

1719
Materialized views in ClickHouse are updated in real time as data flows into the table they are based on, functioning more like continually updating indexes. This is in contrast to other databases where materialized views are typically static snapshots of a query that must be refreshed (similar to ClickHouse [refreshable materialized views](/sql-reference/statements/create/view#refreshable-materialized-view)).
1820

19-
20-
<img src={require('./images/materialized-view-diagram.png').default}
21-
class='image'
22-
alt='Materialized view diagram'
23-
style={{width: '500px'}} />
21+
<img src={materializedViewDiagram}
22+
class="image"
23+
alt="Materialized view diagram"
24+
style={{width: '500px'}} />
2425

2526
## Example {#example}
2627

@@ -410,7 +411,7 @@ In this example, our materialized view can be very simple, selecting only the `P
410411
CREATE TABLE comments_posts_users (
411412
PostId UInt32,
412413
UserId Int32
413-
) ENGINE = MergeTree ORDER BY UserId
414+
) ENGINE = MergeTree ORDER BY UserId
414415

415416

416417
CREATE TABLE comments_null AS comments

docs/materialized-view/refreshable-materialized-view.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ description: How to use materialized views to speed up queries
55
keywords: [refreshable materialized view, refresh, materialized views, speed up queries, query optimization]
66
---
77

8+
import refreshableMaterializedViewDiagram from '@site/static/images/materialized-view/refreshable-materialized-view-diagram.png';
9+
810
[Refreshable materialized views](/sql-reference/statements/create/view#refreshable-materialized-view) are conceptually similar to materialized views in traditional OLTP databases, storing the result of a specified query for quick retrieval and reducing the need to repeatedly execute resource-intensive queries. Unlike ClickHouse’s [incremental materialized views](/materialized-view/incremental-materialized-view), this requires the periodic execution of the query over the full dataset - the results of which are stored in a target table for querying. This result set should, in theory, be smaller than the original dataset, allowing the subsequent query to execute faster.
911

1012
The diagram explains how Refreshable Materialized Views work:
1113

12-
<img src={require('./images/refreshable-materialized-view-diagram.png').default}
13-
class='image'
14-
alt='Refreshable materialized view diagram'
15-
style={{width: '100%', background: 'none' }} />
14+
<img src={refreshableMaterializedViewDiagram}
15+
class="image"
16+
alt="Refreshable materialized view diagram"
17+
style={{width: '100%', background: 'none'}} />
1618

1719
You can also see the following video:
1820

@@ -44,15 +46,15 @@ If you want to force refresh a materialized view, you can use the `SYSTEM REFRES
4446
SYSTEM REFRESH VIEW table_name_mv;
4547
```
4648

47-
You can also cancel, stop, or start a view.
49+
You can also cancel, stop, or start a view.
4850
For more details, see the [managing refreshable materialized views](/sql-reference/statements/system#refreshable-materialized-views) documentation.
4951

5052
## When was a refreshable materialized view last refreshed? {#when-was-a-refreshable-materialized-view-last-refreshed}
5153

5254
To find out when a refreshable materialized view was last refreshed, you can query the [`system.view_refreshes`](/operations/system-tables/view_refreshes) system table, as shown below:
5355

5456
```sql
55-
SELECT database, view, status,
57+
SELECT database, view, status,
5658
last_success_time, last_refresh_time, next_refresh_time,
5759
read_rows, written_rows
5860
FROM system.view_refreshes;
@@ -140,8 +142,8 @@ CREATE TABLE events_snapshot (
140142
ts DateTime32,
141143
uuid String,
142144
count UInt64
143-
)
144-
ENGINE = MergeTree
145+
)
146+
ENGINE = MergeTree
145147
ORDER BY uuid;
146148
```
147149

@@ -240,16 +242,16 @@ In the [dbt and ClickHouse integration guide](/integrations/dbt#dbt) we populate
240242
We can then write the following query can be used to compute a summary of each actor, ordered by the most movie appearances.
241243

242244
```sql
243-
SELECT
245+
SELECT
244246
id, any(actor_name) AS name, uniqExact(movie_id) AS movies,
245247
round(avg(rank), 2) AS avg_rank, uniqExact(genre) AS genres,
246248
uniqExact(director_name) AS directors, max(created_at) AS updated_at
247249
FROM (
248250
SELECT
249251
imdb.actors.id AS id,
250252
concat(imdb.actors.first_name, ' ', imdb.actors.last_name) AS actor_name,
251-
imdb.movies.id AS movie_id, imdb.movies.rank AS rank, genre,
252-
concat(imdb.directors.first_name, ' ', imdb.directors.last_name) AS director_name,
253+
imdb.movies.id AS movie_id, imdb.movies.rank AS rank, genre,
254+
concat(imdb.directors.first_name, ' ', imdb.directors.last_name) AS director_name,
253255
created_at
254256
FROM imdb.actors
255257
INNER JOIN imdb.roles ON imdb.roles.actor_id = imdb.actors.id

0 commit comments

Comments
 (0)