[英]Azure TableStorage - Performance
I have to make a query on an Azure table storage where I have the following setup: RowKey, PartitionKey, ThirdColumn 我必须在具有以下设置的Azure表存储上进行查询: RowKey,PartitionKey,ThirdColumn
The RowKey is unique, and the Partitionkey corelates with ThirdColumn, meaning all third columns with the value " Y ", will have the partition key " X ". RowKey是唯一的,并且Partitionkey与ThirdColumn关联在一起,这意味着所有第三列的值为“ Y ”,都将具有分区键“ X ”。
I have to get all entities with partition key X , by using the ThirdColumn value. 我必须通过使用ThirdColumn值来获取所有具有分区键X的实体。 This will not be performant because Y is neither PartitionKey or RowKey.
由于Y既不是PartitionKey也不是RowKey,因此这将无法执行。
Question is: Does it make sense to do a .FirstOrDefault() on the third column, in order to get an entity (any entity), and then do a query using the PartitionKey ? 问题是:为了获取实体(任何实体),然后在第三列上执行.FirstOrDefault(),然后使用PartitionKey进行查询,是否有意义? I think it would be better because then it doesn't have to search on different machines for the data.
我认为这样会更好,因为那样就不必在其他计算机上搜索数据了。
Regards, 问候,
Why not make the PartitionKey a combined value of X and Y? 为什么不将PartitionKey设为X和Y的组合值? Like "MyValueofX_MyValueofY"?
像“ MyValueofX_MyValueofY”一样?
Or if you don't have the value of X when you query, just duplicate the information with a different order, for example: 或者,如果在查询时没有X的值,则只需以不同的顺序复制信息,例如:
PK: X RK: Z Column: Y PK:X RK:Z列:Y
PK: Y RK: Z Column: X PK:Y RK:Z列:X
That way, you can query the record when you have X and when you have Y. 这样,您可以在拥有X和Y时查询记录。
Check Designing a Scalable Partition Strategy . 检查设计可扩展分区策略 。
I think you can look at the articles below: 我认为您可以查看以下文章:
https://msdn.microsoft.com/en-us/library/azure/dd894039.aspx https://msdn.microsoft.com/zh-CN/library/azure/dd894039.aspx
and try this code to get the first 1 entity: 并尝试使用以下代码获取第一个1实体:
var query = (from entity in context.CreateQuery<Customer>("Top1Customers")
select entity).Take(1);
Then you can write it into a method called First() 然后可以将其写入名为First()的方法中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.