Sam*_*Sam 8 azure azure-table-storage azure-tablequery
在Azure表存储中,是否可以使用StartsWith或其他某些运算符(例如包含等)查询PartitionKey.
我知道我可以用RowKeys做到这一点但是可以用PartitionKeys做到吗?
后续问题是:即使它可行,是否可取?PartitionKey应该是完全匹配 - 比如,出于性能原因?
ric*_*aux 16
这是使用GreaterThanOrEqual和LessThan运算符的示例,作为目标列名称的扩展.
过滤器结合了两个部分:
例如,startsWith前缀"CAR"将准备类似的东西s >= "CAR" && s < "CAS".
public static string GetStartsWithFilter(this string columnName, string startsWith)
{
var length = startsWith.Length - 1;
var nextChar = startsWith[length] + 1;
var startWithEnd = startsWith.Substring(0, length) + (char)nextChar;
var filter = TableQuery.CombineFilters(
TableQuery.GenerateFilterCondition(columnName, QueryComparisons.GreaterThanOrEqual, startsWith),
TableOperators.And,
TableQuery.GenerateFilterCondition(columnName, QueryComparisons.LessThan, startWithEnd));
return filter;
}
Run Code Online (Sandbox Code Playgroud)
用法:
var query = new TableQuery<MyTableEntity>().Where(myColumnName.GetStartsWithFilter(prefix));
Run Code Online (Sandbox Code Playgroud)
Ped*_*ias -3
好消息是,您可以进行部分匹配,只要命中的分区数量很少,您就会获得“良好”的性能。如果您有大量分区键,性能将会受到影响。
我可以尝试总结一篇关于此的优秀文章,但它已经写好了,所以如果您将浏览器指向以下链接,您应该了解有关分区、行键和预期性能的所有知识:
https://msdn.microsoft.com/en-us/library/azure/hh508997.aspx
| 归档时间: |
|
| 查看次数: |
4080 次 |
| 最近记录: |