You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -1541,6 +1547,170 @@ support preserving stats between role reload
1541
1547
(see [tarantool/metrics#334](https://github.com/tarantool/metrics/issues/334)),
1542
1548
thus this feature will be unsupported for `metrics` driver.
1543
1549
1550
+
### Read view
1551
+
1552
+
A read view is an in-memory snapshot of data on instance that isn’t affected by future data modifications. Read views allow you to retrieve data using the `read_view_object:select()` and `read_view_object:pairs()` operations.
1553
+
1554
+
Read views can be used to make complex analytical queries. This reduces the load on the main database and improves RPS for a single Tarantool instance.
1555
+
1556
+
Read views have the following limitations:
1557
+
1558
+
* Only the memtx engine is supported.
1559
+
* Read view can be used starting from Tarantool Enterprise v2.11.0.
1560
+
* There is no clusterwide readview support. For a sharded cluster, we open a readview on each storage. Due to a cluster's distributed nature, it is not guaranteed that they will open simultaneously.
1561
+
1562
+
#### Creating a read view
1563
+
1564
+
To create a read view, call the `crud.readview()` function.
1565
+
1566
+
```lua
1567
+
localrv=crud.readview(opts)
1568
+
```
1569
+
1570
+
where:
1571
+
1572
+
*`opts`:
1573
+
*`name` (`?string`) - name of the read view
1574
+
*`timeout` (`?number`) - `vshard.call` timeout (in seconds)
1575
+
1576
+
**Example:**
1577
+
1578
+
```lua
1579
+
localrv=crud.readview({name='foo', timeout=3})
1580
+
```
1581
+
1582
+
#### Closing a read view
1583
+
1584
+
When a read view is no longer needed, close it using the `read_view_object:close()` method because a read view may consume a substantial amount of memory.
1585
+
1586
+
```lua
1587
+
localrv=crud.readview()
1588
+
rv:close(opts)
1589
+
```
1590
+
1591
+
where:
1592
+
1593
+
*`opts`:
1594
+
*`timeout` (`?number`) - `vshard.call` timeout (in seconds)
1595
+
1596
+
A read view is also closed implicitly when the read view object is collected by the Lua garbage collector.
1597
+
1598
+
**Example:**
1599
+
1600
+
```lua
1601
+
localrv=crud.readview()
1602
+
rv:close({timeout=3})
1603
+
```
1604
+
1605
+
#### Read view select
1606
+
1607
+
`read_view_object:select()` supports multi-conditional selects, treating a cluster as a single space, same as `crud.select`.
0 commit comments