Understanding Partition Id and Time to live columns in DataVerse Elastic tables

Hello everyone and welcome to my blog. In today’s blog I will discuss about Elastic tables in DataVerse, a preview feature recently released by Microsoft.

In this blog we will discuss about two important columns in Elastic tables – Partition Id and Time to live. If you are not aware of elastic tables in DataVerse, please go through the pre-release documentation of Microsoft on this topic.

Through my blog I share interesting tips and discuss on latest releases of Microsoft.NET technologies, Dynamics 365 and Power Platform, SharePoint and Client scripting libraries. Please subscribe to my blog to stay updated.

Creating an elastic table in PowerApps is fairly easy. Just like standard tables, you can create an Elastic table from the maker portal. The only difference is to set the Type of the table to Elastic as shown in the below illustration.

Once the table is created, navigate to columns and you will notice two columns are created which are not there in a standard table.

  1. Partition id
  2. Time to live

Let’s understand the importance of these two columns.

Let’s first start with Partition Id. What exactly is this field used for?

To understand Partition Id, we should first understand the benefits of Elastic tables over standard relational tables. To begin with, Elastic tables created in DataVerse are stored in Azure Cosmos DB and they can scale horizontally.

They can handle large amounts of data and high levels of throughput with low latency. To achieve the high volume of read and write requests, Elastic tables uses Cosmos DB partitioning to meet the performance. The rows are divided into a logical subset using the Partition Id value for each row.

For example – If your elastic table is storing device information, the Partition Id column can store the category of the Device for each row. There shall be logical row groupings based on the value of the Partition Id column.

The Partition Id column is editable. However you can only enter data in the column when you create the record. Once you set a value for Partition Id column for a row, you won’t be able to change it.

Check for the below illustration. Here when I create ‘Sample record 3 ‘, I am able to enter a value for Partition Id. But when I try to enter a value for an existing record, it does not save.

If you haven’t set the Partition Id column when you create a record, the value will remain null and you won’t be able to change. Below is the WebAPI query result for the elastic table. As you can see, the partition id column is null for ‘Sample record 1’ row.

{"@odata.context":"https://orgbb2b2550.api.crm.dynamics.com/api/data/v9.2/$metadata#cr129_customerinfos(cr129_name,partitionid)","value":[{"@odata.etag":"W/\"e2009a91-0000-0700-0000-6499346c0000\"","cr129_name":"Sample record 3","partitionid":"3","cr129_customerinfoid":"833ca544-ed13-ee11-8f6e-000d3a36d4e2","versionnumber":638233588285108839},{"@odata.etag":"W/\"e900511f-0000-0700-0000-649934380000\"","cr129_name":"Sample record 1","partitionid":null,"cr129_customerinfoid":"07f8d772-e513-ee11-8f6e-000d3a36d4e2","versionnumber":638233587763293878},{"@odata.etag":"W/\"4000d0c3-0000-0700-0000-649927710000\"","cr129_name":"Sample Record 2","partitionid":"2","cr129_customerinfoid":"07600388-e513-ee11-8f6e-000d3a36d4e2","versionnumber":638233555055610191}]}

Now let’s shift our attention to Time to live column. This value is used to determine how long the record will persist in the database.

If a value is specified for this field, the row will automatically be deleted after the specified time. The value is in seconds.

In the below illustration, I have set the value for Time to live to 5 seconds. After 5 seconds when I refresh the table, the row is no longer available.

What if the value is not there initially and I set a value at a later point in time. In that case, it will be the specified duration (in seconds) from the time when when the value was set.

Hope this helped. For similar interesting topics on Microsoft.NET and Power platform, you can subscribe to my blog.

Debajit Dutta
Business Solutions MVP