Skip to content

Commit a9675dc

Browse files
authored
Document REFRESH MATERIALIZED VIEW INTERVAL (#181)
1 parent 1e5764a commit a9675dc

File tree

3 files changed

+58
-29
lines changed

3 files changed

+58
-29
lines changed

documentation/reference/sql/refresh-mat-view.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,37 @@ description:
77

88
:::info
99

10-
Materialized View support is now generally available (GA) and ready for production use.
10+
Materialized View support is now generally available (GA) and ready for
11+
production use.
1112

12-
If you are using versions earlier than `8.3.1`, we suggest you upgrade at your earliest convenience.
13+
If you are using versions earlier than `8.3.1`, we suggest you upgrade at your
14+
earliest convenience.
1315

1416
:::
1517

1618
`REFRESH MATERIALIZED VIEW` refreshes a materialized view. This is helpful when
1719
a view becomes invalid, and no longer refreshes incrementally.
1820

19-
When the FULL keyword is specified, this command deletes the data in the target
20-
materialized view and inserts the results of the query into the view. It also
21-
marks the materialized view as valid, reactivating the incremental refresh
21+
When the `FULL` keyword is specified, this command deletes the data in the
22+
target materialized view and inserts the results of the query into the view. It
23+
also marks the materialized view as valid, reactivating the incremental refresh
2224
processes.
2325

2426
When the `INCREMENTAL` keyword is used, the `REFRESH` command schedules an
2527
incremental refresh of the materialized view. Usually, incremental refresh is
2628
automatic, so this command is useful only in niche situations when incremental
2729
refresh is not working as expected, but the view is still valid.
2830

31+
When the `INTERVAL` keyword is specified, this command refreshes the data in the
32+
specified time interval only. This command is useful for a valid materialized
33+
view with configured
34+
[`REFRESH LIMIT`](/docs/reference/sql/alter-mat-view-set-refresh-limit/). That's
35+
because inserted base table rows with timestamps older than the refresh limit
36+
are ignored by incremental refresh, so interval refresh may be used to
37+
recalculate materialized view on older rows. Interval refresh does not affect
38+
incremental refresh, e.g. it does not update the last base table transaction
39+
used by incremental refresh.
40+
2941
## Syntax
3042

3143
![Flow chart showing the syntax of the REFRESH MATERIALIZED VIEW keyword](/images/docs/diagrams/refreshMatView.svg)
@@ -40,6 +52,10 @@ REFRESH MATERIALIZED VIEW trades_1h FULL;
4052
REFRESH MATERIALIZED VIEW trades_1h INCREMENTAL;
4153
```
4254

55+
```questdb-sql
56+
REFRESH MATERIALIZED VIEW trades_1h INTERVAL FROM '2025-05-05T01:00:00.000000Z' TO '2025-05-05T02:00:00.000000Z';
57+
```
58+
4359
## See also
4460

4561
For more information on the concept, see the the

static/images/docs/diagrams/.railroad

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ alterMatViewSetRefreshLimit
394394
::= 'ALTER' 'MATERIALIZED' 'VIEW' viewName 'SET' 'REFRESH' 'LIMIT' n ('HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS')
395395

396396
refreshMatView
397-
::= 'REFRESH' 'MATERIALIZED' 'VIEW' viewName ('FULL' | 'INCREMENTAL')
397+
::= 'REFRESH' 'MATERIALIZED' 'VIEW' viewName ('FULL' | 'INCREMENTAL' | ('INTERVAL' 'FROM' fromTimestamp 'TO' toTimestamp))
398398

399399
dropMatView
400400
::= 'DROP' 'MATERIALIZED' 'VIEW' viewName
Lines changed: 36 additions & 23 deletions
Loading

0 commit comments

Comments
 (0)