Reputation: 903
In DocumentDb, how should I partition this? Should I use partitionkey or not? I don't think I can do "/address/state" since its collection... or can I? Should I use "/Id" or "/name"? is that even a good idea when those are mostly unique since id is Guid generated by documentDB and name is almost always unique. So which one should I use? I guess I may query by name but i thought partitionkey should be documents which can be grouped, by such as state, or city, or parentId.
Should I not use partitionKey at all? And this applies to my AspNetuser schema user table in documentDb. Which property should I use for that for the partitionKey?
public class Business
{
[JsonProperty(PropertyName = "id")]
public string Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "description")]
public string Description{ get; set; }
[JsonProperty(PropertyName = "addresses")]
public List<Address> Addresses{ get; set; }
//more columns...
}
public class Address
{
[JsonProperty(PropertyName = "street")]
public string Street{ get; set; }
[JsonProperty(PropertyName = "city")]
public string City{ get; set; }
[JsonProperty(PropertyName = "state")]
public string State{ get; set; }
}
Upvotes: 3
Views: 2960
Reputation: 27825
Should I use partitionkey or not?
In order to decide if you should partition your collection, here are some key points to consider:
Single-partition collections: have lower price options and the ability to execute queries and perform transactions across all collection data. They have the scalability and storage limits of a single partition (10GB and 10,000 RU/s). You do not have to specify a partition key for these collections. For scenarios that do not need large volumes of storage or throughput, single partition collections are a good fit.
Partitioned collections: can span multiple partitions and support very large amounts of storage and throughput. You must specify a partition key for these collection.
I don't think I can do "/address/state" since its collection... or can I?
A partition key can be a property or path within your documents.
Should I use "/Id" or "/name"? is that even a good idea when those are mostly unique since id is Guid generated by documentDB and name is almost always unique. So which one should I use?
An ideal partition key is one that appears frequently as a filter in your queries and has sufficient cardinality to ensure your solution is scalable. In “Designing for partitioning” section, you can find two key considerations for choosing a partition key and a few real-world scenarios, for detailed information, please check the link.
Upvotes: 2