Skip to content

Commit 5394a8c

Browse files
committed
First copy edit
1 parent 7103071 commit 5394a8c

File tree

1 file changed

+84
-82
lines changed

1 file changed

+84
-82
lines changed
Lines changed: 84 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
---
2-
title: Materialized Views for Azure Cosmos DB API for Cassandra. (Preview)
2+
title: Materialized Views for Azure Cosmos DB API for Apache Cassandra (preview)
33
description: This documentation is provided as a resource for participants in the preview of Azure Cosmos DB Cassandra API Materialized View.
44
author: dileepraotv-github
5+
ms.author: turao
56
ms.service: cosmos-db
6-
ms.subservice: cosmosdb-cassandra
7+
ms.subservice: apache-cassandra
78
ms.topic: how-to
8-
ms.date: 11/09/2022
9-
ms.author: turao
9+
ms.date: 11/17/2022
10+
ms.custom: ignite-2022
1011
---
1112

12-
# Materialized views for Azure Cosmos DB API for Cassandra operations (Preview)
13+
# Materialized Views for Azure Cosmos DB API for Apache Cassandra (preview)
14+
1315
[!INCLUDE[Cassandra](../includes/appliesto-cassandra.md)]
1416

1517
> [!IMPORTANT]
16-
> Materialized Views for Azure Cosmos DB API for Cassandra is currently in preview. You can enable this feature from the portal.
17-
18+
> Materialized Views for API for Cassandra is currently in preview. You can enable this feature from the portal.
19+
>
1820
> Materialized View preview version is provided without a service level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities.
21+
>
1922
> For more information, see [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
2023
2124
## Feature overview
@@ -24,33 +27,33 @@ Materialized Views when defined will help provide a means to efficiently query a
2427

2528
You can query a column store without specifying a partition key by using Secondary Indexes. However, the query won't be effective for columns with high cardinality (scanning through all data for a small result set) or columns with low cardinality. Such queries end up being expensive as they end up being a cross partition query.
2629

27-
With Materialized view, you can
28-
- Use as Lookup table or Mapping table and save cross partition scans that reduce expensive queries
29-
- Provide SQL based conditional predicate to populate only certain columns and certain data that meet the pre-condition
30-
- Real time MVs that simplify real time event based scenarios where customers today use Change feed trigger for precondition checks to populate new collections"
30+
With Materialized view, you can:
31+
32+
- Use as Lookup table or Mapping table and save cross partition scans that reduce expensive queries.
33+
- Provide SQL based conditional predicate to populate only certain columns and certain data that meet the pre-condition.
34+
- Real time MVs that simplify real time event based scenarios where customers today use Change feed trigger for precondition checks to populate new collections".
3135

3236
## Main benefits
3337

34-
- With Materialized View (Server side denormalization), you can avoid multiple independent tables and client side denormalization.
38+
- With Materialized View (Server side denormalization), you can avoid multiple independent tables and client side denormalization.
3539
- Materialized view feature takes on the responsibility of updating views in order to keep them consistent with the base table. With this feature, you can avoid dual writes to the base table and the view.
3640
- Materialized Views helps optimize read performance
3741
- Ability to specify throughput for the materialized view independently
3842
- Based on the requirements to hydrate the view, you can configure the MV builder layer appropriately.
3943
- Speeding up write operations as it only needs to be written to the base table.
4044
- Additionally, This implementation on Cosmos DB is based on a pull model, which doesn't affect the writer performance.
4145

42-
43-
4446
## How to get started?
4547

46-
New Cassandra API accounts with Materialized Views enabled can be provisioned on your subscription by using REST API calls from az CLI.
48+
New Cassandra API accounts with Materialized Views enabled can be provisioned on your subscription by using REST API calls from Azure CLI.
4749

4850
### Log in to the Azure command line interface
4951

50-
Install Azure CLI as mentioned at [How to install the Azure CLI | Microsoft Docs](/cli/azure/install-azure-cli) and log on using the below:
51-
```azurecli-interactive
52-
az login
53-
```
52+
Install Azure CLI as mentioned at [How to install the Azure CLI | Microsoft Docs](/cli/azure/install-azure-cli) and log in:
53+
54+
```azurecli
55+
az login
56+
```
5457

5558
### Enable Materialized view feature on DB account
5659

@@ -68,100 +71,97 @@ Install Azure CLI as mentioned at [How to install the Azure CLI | Microsoft Docs
6871

6972
:::image type="content" source="./media/materialized-view/Enable_mv_on_portal.png" alt-text="Screenshot to enable Materialized view feature on portal Azure Cosmos DB API for Cassandra":::
7073

71-
72-
#### Using AZ CLI
74+
#### Using Azure CLI
7375

7476
Please use this link to install Microsoft Azure CLI 'cosmosdb-preview' Extension: [Azure CLI extension overview](https://learn.microsoft.com/cli/azure/azure-cli-extensions-overview)
7577

76-
Refer to this link on documentation for AZ CLI command for enabling Materialized View on account: [AZ CLI documentation](https://github.com/Azure/azure-cli-extensions/tree/main/src/cosmosdb-preview#enable-materialized-views-on-a-existing-cosmosdb-account)
78+
Refer to this link on documentation for Azure CLI command for enabling Materialized View on account: [Azure CLI documentation](https://github.com/Azure/azure-cli-extensions/tree/main/src/cosmosdb-preview#enable-materialized-views-on-a-existing-cosmosdb-account)
7779

78-
Enable Materialized View for account using command as in below example
79-
80-
```azurecli-interactive
81-
az cosmosdb update --resource-group "TestRG" --name "testaccount" --enable-materialized-views true --capabilities "CassandraEnableMaterializedViews"
82-
```
80+
Enable Materialized View for account using `az cosmosdb update`.
8381

82+
```azurecli
83+
az cosmosdb update --resource-group "TestRG" --name "testaccount" --enable-materialized-views true --capabilities "CassandraEnableMaterializedViews"
84+
```
8485

8586
#### Using AZ REST
8687

87-
```azurecli-interactive
88+
```azurecli
8889
az rest --method PATCH --uri https://management.azure.com/subscriptions/074d02eb-4d74-486a-b299-b262264d1536/resourcegroups/TestRG/providers/Microsoft.DocumentDb/databaseAccounts/testaccount?api-version=2021-11-15-preview --body @body.txt
89-
90-
{
91-
92-
"properties":
93-
94-
{
95-
96-
"capabilities": [{ "name": "CassandraEnableMaterializedViews" }],
97-
98-
"enableMaterializedViews": true
99-
100-
}
101-
102-
}
10390
```
10491

105-
106-
92+
```json
93+
{
94+
"properties": {
95+
"capabilities": [
96+
{
97+
"name": "CassandraEnableMaterializedViews"
98+
}
99+
],
100+
"enableMaterializedViews": true
101+
}
102+
}
103+
```
107104

108105
### Under the hood
109106

110-
Azure Cosmos DB Cassandra API uses a MV builder compute layer to maintain Materialized views.
107+
Azure Cosmos DB Cassandra API uses a MV builder compute layer to maintain Materialized views.
111108

112-
Customer gets flexibility to configure the MV builder compute instances depending on the latency and lag requirements to hydrate the views. From a technical stand point, this compute layer helps manage connections between partitions in a more efficient manner even when the data size is huge and the number of partitions is high.
109+
Customer gets flexibility to configure the MV builder compute instances depending on the latency and lag requirements to hydrate the views. From a technical stand point, this compute layer helps manage connections between partitions in a more efficient manner even when the data size is huge and the number of partitions is high.
113110

114111
The compute containers are shared among all MVs within the database account. Each provisioned compute container spawns off multiple tasks that read change feed from base table partitions and write data to MV (which is also another table) after transforming them as per MV definition for every MV in the database account.
115112

116-
### Create materialized view builder
113+
### Create a materialized view builder
117114

118-
#### Using Portal
115+
#### Using the Azure portal
119116

120117
1. Sign in to the [Azure portal](https://portal.azure.com/).
121118

122-
2. Navigate to your Azure Cosmos DB API for Cassandra account.
119+
1. Navigate to your Azure Cosmos DB API for Cassandra account.
120+
121+
1. Go to the **Materialized View Builder** pane underneath the **Settings** section.
123122

124-
3. Go to the **Materialized View Builder** pane underneath the **Settings** section. (this will show up only when Materialized View feature is enabled as mentioned earlier in the documentation)
123+
> [!NOTE]
124+
> This pane will show up only when Materialized View feature is enabled as mentioned previously in the documentation.
125125
126-
4. Select **Materialized View Builder**.
126+
1. Select **Materialized View Builder**.
127127

128-
5. Configure as required.
128+
1. Configure the builder.
129129

130130
:::image type="content" source="./media/materialized-view/provision_mv_builder.png" alt-text="Provision Materialized view builder on portal for Azure Cosmos DB API for Cassandra":::
131131

132-
#### Using AZ CLI
132+
#### Using Azure CLI
133133

134134
Please use this link to install Microsoft Azure CLI 'cosmosdb-preview' Extension: [Azure CLI extension overview](https://learn.microsoft.com/cli/azure/azure-cli-extensions-overview)
135135

136-
Refer to this link on documentation for AZ CLI command to create Materialized View builder: [AZ CLI documentation](https://github.com/Azure/azure-cli-extensions/tree/main/src/cosmosdb-preview#create-a-cosmosdb-materialized-views-builder-service-resource)
136+
Refer to this link on documentation for Azure CLI command to create Materialized View builder: [Azure CLI documentation](https://github.com/Azure/azure-cli-extensions/tree/main/src/cosmosdb-preview#create-a-cosmosdb-materialized-views-builder-service-resource)
137137

138138
Enable Materialized View for account using command as in below example
139139

140-
```azurecli-interactive
140+
```azurecli
141141
az cosmosdb service create --resource-group "TestRG" --account-name "testaccount" --name "MaterializedViewsBuilder" --kind "MaterializedViewsBuilder" --count 1 --size "Cosmos.D4s"
142142
```
143143

144-
#### Using AZ REST
144+
#### Using the REST API and Azure CLI
145145

146146
Following this step, you'll also need to provision a Materialized View Builder:
147147

148-
```
148+
```azurecli
149149
az rest --method PUT --uri https://management.azure.com/subscriptions/{{subscriptionId}}/resourcegroups/{{resourceGroup}}/providers/Microsoft.DocumentDb/databaseAccounts/{{accountName}}/services/materializedViewsBuilder?api-version=2021-07-01-preview --body @body.txt
150+
```
150151

151-
body.txt content:
152+
```json
152153
{
153-
"properties":
154-
{
154+
"properties": {
155155
"serviceType": "materializedViewsBuilder",
156156
"instanceCount": 1,
157157
"instanceSize": "Cosmos.D4s"
158158
}
159159
}
160160
```
161161

162-
Wait for a couple of minutes and check the status using the below, the status in the output should have become Running:
162+
Wait for a couple of minutes and check the status using `az rest` again, the status in the output should now be `Running`:
163163

164-
```
164+
```azurecli
165165
az rest --method GET --uri https://management.azure.com/subscriptions/{{subscriptionId}}/resourcegroups/{{resourceGroup}}/providers/Microsoft.DocumentDb/databaseAccounts/{{accountName}}/services/materializedViewsBuilder?api-version=2021-07-01-preview
166166
```
167167

@@ -173,11 +173,11 @@ Once your account and Materialized View Builder is set up, you should be able to
173173

174174
Install standalone CQLSH tool using the link [CQLSH Tool](https://learn.microsoft.com/azure/cosmos-db/cassandra/support#cql-shell)
175175

176-
Update Connection String
176+
Update Connection String
177177

178178
Quickstart: [API for Cassandra with CQLSH - Azure Cosmos DB | Microsoft Learn](https://learn.microsoft.com/azure/cosmos-db/cassandra/manage-data-cqlsh#update-your-connection-string)
179179

180-
CQL commands to create MV
180+
CQL commands to create MV
181181

182182
```
183183
test@cqlsh> CREATE KEYSPACE IF NOT EXISTS uprofile
@@ -195,15 +195,17 @@ test@cqlsh> INSERT INTO uprofile.user (user_id, user_name, user_bcity) VALUES (
195195
... ;
196196
197197
test@cqlsh> SELECT * FROM user_by_bcity;
198+
```
198199

200+
```output
199201
user_bcity | user_id | user_name
200202
------------+---------+-----------
201203
New York | 101 | johnjoe
202204
New York | 102 | james
203205
204206
(2 rows)
205-
206207
```
208+
207209
#### Using Resource Provider (RP)
208210

209211
You can use RP to Create/Update Cassandra View as given below.
@@ -220,6 +222,7 @@ Cassandra Resources - Update Cassandra View Throughput - REST API (Azure Cosmos
220222
## Caveats and current limitations
221223

222224
However, there are a few caveats with Cosmos DB Cassandra API’s preview implementation of Materialized Views:
225+
223226
- Materialized Views can't be created on a table that existed before the account was onboarded to support materialized views. Create new table after account is onboarded on which materialized views can be defined.
224227
- For the MV definition’s WHERE clause, only “IS NOT NULL” filters are currently allowed.
225228
- After a Materialized View is created against a base table, ALTER TABLE ADD operations aren't allowed on the base table’s schema - they're allowed only if none of the MVs have select * in their definition.
@@ -228,11 +231,11 @@ However, there are a few caveats with Cosmos DB Cassandra API’s preview implem
228231
- Materialized View may become inconsistent with the source table for a small number of rows after automatic regional failover. Our suggestion is to rebuild the MV in this case.
229232
- At the moment, creating MV builder instances with 32 cores is not supported. If needed, you can provision multiple instances with smaller number of cores.
230233

231-
In addition to the above, note the following limitations
234+
In addition to the above, note the following limitations
232235

233236
### Availability zones limitations
234237

235-
- Materialized views can't be enabled on an account that has Availability zone enabled regions.
238+
- Materialized views can't be enabled on an account that has Availability zone enabled regions.
236239
- Adding a new region with Availability zone is not supported once “enableMaterializedViews” is set to true on the account.
237240

238241
### Periodic backup and restore limitations
@@ -248,11 +251,8 @@ Materialized views aren't automatically restored with the restore process. Custo
248251
- Deleting base table is not allowed if at least one MV is defined on it. All the MVs must first be deleted and then the base table can be deleted.
249252
- Defining materialized views on containers with Static columns is not allowed
250253

251-
252-
253254
## Frequently asked questions (FAQs) …
254255

255-
256256
### What transformations/actions are supported?
257257

258258
- Specifying a partition key that is different from base table partition key.
@@ -271,28 +271,29 @@ Autoscaling for MV builder is not available right now. The MV builder instances
271271

272272
The proposed billing model will be to charge the customers for:
273273

274-
**MV Builder compute nodes** MV Builder Compute – Single tenant layer
274+
**MV Builder compute nodes** MV Builder Compute – Single tenant layer
275275

276-
**Storage** The OLTP storage of the base table and MV based on existing storage meter for Containers. LogStore won't be charged.
276+
**Storage** The OLTP storage of the base table and MV based on existing storage meter for Containers. LogStore won't be charged.
277277

278-
**Request Units** The provisioned RUs for base container and Materialized View.
278+
**Request Units** The provisioned RUs for base container and Materialized View.
279279

280280
### What are the different SKUs that will be available?
281+
281282
Refer to Pricing - [Azure Cosmos DB | Microsoft Azure](https://azure.microsoft.com/pricing/details/cosmos-db/) and check instances under Dedicated Gateway
282283

283284
### What type of TTL support do we have?
284285

285-
TTL from base table rows will be applied on MV as well. Setting table level TTL on MV is not allowed.
286+
TTL from base table rows will be applied on MV as well. Setting table level TTL on MV is not allowed.
287+
288+
### Initial troubleshooting if MVs aren't up to date:
286289

287-
### Initial troubleshooting if MVs aren't up to date:
288290
- Check if MV builder instances are provisioned
289291
- Check if enough RUs are provisioned on the base table
290292
- Check for unavailability on Base table or MV
291293

292294
### What type of monitoring is available in addition to the existing monitoring for Cassandra API?
293295

294-
295-
- Max Materialized View Catchup Gap in Minutes – Value(t) indicates rows written to base table in last ‘t’ minutes is yet to be propagated to MV.
296+
- Max Materialized View Catchup Gap in Minutes – Value(t) indicates rows written to base table in last ‘t’ minutes is yet to be propagated to MV.
296297
- Metrics related to RUs consumed on base table for MV build (read change feed cost)
297298
- Metrics related to RUs consumed on MV for MV build (write cost)
298299
- Metrics related to resource consumption on MV builders (CPU, memory usage metrics)
@@ -305,13 +306,13 @@ TTL from base table rows will be applied on MV as well. Setting table level TTL
305306

306307
:::image type="content" source="./media/materialized-view/monitoring4.png" alt-text="Max CPU Metrics Screenshot for Materialized view feature on portal Azure Cosmos DB API for Cassandra":::
307308

308-
309309
### What are the restore options available for MVs?
310+
310311
MVs can't be restored. Hence, MVs will need to be recreated once the base table is restored.
311312

312313
### Can you create more than one view on a base table?
313314

314-
Multiple views can be created on the same base table. Limit of five views is enforced.
315+
Multiple views can be created on the same base table. Limit of five views is enforced.
315316

316317
### How is uniqueness enforced on the materialized view? How will the mapping between the records in base table to the records in materialized view look like?
317318

@@ -327,12 +328,13 @@ No. Materialized Views can't be created on a table that existed before the accou
327328

328329
### What are the conditions on which records won't make it to MV and how to identify such records?
329330

330-
Below are some of the identified cases where data from base table can't be written to MV as they violate some constraints on MV table-
331+
Below are some of the identified cases where data from base table can't be written to MV as they violate some constraints on MV table:
332+
331333
- Rows that don’t satisfy partition key size limit in the materialized views (2kb limit)
332334
- Rows that don't satisfy clustering key size limit in materialized views (1kb limit)
333-
335+
334336
Currently we drop these rows but plan to expose details related to dropped rows in future so that the user can reconcile the missing data.
335337

336338
### Materialized View with Customer Managed Keys
337339

338-
To create an account with support for customer managed keys and materialized views please reach out to Cosmos DB support team.
340+
To create an account with support for customer managed keys and materialized views please reach out to Cosmos DB support team.

0 commit comments

Comments
 (0)