Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count rows within partition in Azure table storage

I've seen various questions around SO about how to get the total row count of an Azure storage table, but I want to know how to get the number of rows within a single partition.

How can I do this while loading a minimal amount of entity data into memory?

like image 933
goelze Avatar asked Aug 16 '16 14:08

goelze


People also ask

How do I check data on Azure table storage?

To view table data. In Cloud Explorer, open the Azure node, and then open the Storage node. Open the storage account node that you are interested in, and then open the Tables node to see a list of tables for the storage account. Open the shortcut menu for a table, and then select View Table.

What is the maximum size of an entity in Azure Table Storage?

An entity in Azure Storage can be up to 1MB in size. An entity in Azure Cosmos DB can be up to 2MB in size. Properties: A property is a name-value pair. Each entity can include up to 252 properties to store data.

What is partition key in Azure table?

The partition key is a unique identifier for the partition within a given table, specified by the PartitionKey property. The partition key forms the first part of an entity's primary key. The partition key may be a string value up to 1 KiB in size.


1 Answers

As you may already know that there's no Count like functionality available in Azure Tables. In order to get the total number of entities (rows) in a Partition (or a Table), you have to fetch all entities.

You can reduce the response payload by using a technique called Query Projection. A query projection allows you to specify the list of entity attributes (columns) that you want table service to return. Since you're only interested in total count of entities, I would recommend that you only fetch PartitionKey back. You may find this blog post helpful for understanding about Query Projection: https://blogs.msdn.microsoft.com/windowsazurestorage/2011/09/15/windows-azure-tables-introducing-upsert-and-query-projection/.

like image 182
Gaurav Mantri Avatar answered Sep 18 '22 21:09

Gaurav Mantri