Azure table storage partition key and row key for one key entity

Viewed 84

What is the best practice when choosing partition & row key for entities with one important key?

Sample entities:

  • Device1:
    • ID: AB1234567
    • IsRunning: Yes
    • IsUpdating: No
  • Device2:
    • ID: AB7654321
    • IsRunning: Yes
    • IsUpdating: Yes

I saw this post that suggests splitting the ID as partition key and row key.

But Azure documentation actually recommends only using partition key when the entity only has one key property. It doesn't say what should be set as the row key though.. should it be empty? Or maybe a default value like '0'?

The expected records is maybe in the tens of thousands. Currently ~10k but growing

1 Answers

PartitionKey in Table Storage

In Table Storage, you need to decide on the PartitionKey yourself. Eventually, you are responsible for the output you will get on your system. If you put every entity in the same partition, you will be limited to the size of the storage machines for the amount of storage you can use. Also, you will be constraining the maximal throughput as there are lots of entities in the same partition.

RowKey in Table Storage

A RowKey in Table Storage is a very important thing: it is “primary key” within a partition. Combination of PartitionKey and RowKey form the composite unique identifier for an entity. Within one PartitionKey, you can only have unique RowKeys. If you use multiple partitions, the same RowKey can be reused in every partition.

This article by Maarten Balliauw will help you to decide What is the best practice when choosing partition & row key for entities.

Related