Azure表按行键查询作为条件 [英] Azure tables query by rowkey as condition

查看:46
本文介绍了Azure表按行键查询作为条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用查询通过行键获取一个或多个记录有多好?查询仅检查行键是否有意义?我知道您可以组合主键+行键并获取特定记录,然后通过特定分区键获取所有记录(因此所有相关数据将快速返回).

How good is to use a query to get record/records by rowkey? Does it make any sense of having queries that check's only the row key? I know you can combine primarykey + rowkey and get a specific record or then get all records by a specific partition key (so all related data will be returned fast).

我猜想,如果您进行查询以查找行键,那么当您查询包含大量项目的表时,性能将下降,因为它必须遍历所有项目.

I guess that if you make a query that looks for rowkey then the performance will go down when you query a table with high amount of items as it has to look through all of them.

当通过行键(单独)查询时,你们能说出一个案例吗?我不是要检索结果,而是要发送到Azure存储以返回项目的查询中.

Can you guys tell a case when querying by rowkey (alone) make's sens? I don't mean into the results retrieved but in the query sent to azure storage to return the items.

推荐答案

Azure Table Storage(截至目前)构建了两个索引,可以使查找速度更快/更快,分别是PartitionKey和Rowkey.如果您有一个分区(或很少的分区),则仅通过行键查询才有意义.如果您有很多分区,而仅指定行键,则必须查找所有分区.

Azure Table Storage (as of now) builds two indexes that makes lookups faster/fast which are the PartitionKey and Rowkey. Querying by the rowkey only would make sense if you had one partition (or very few partitions). If you have a lot of partitions and you just specify the rowkey it will have to look up all partitions.

例如,假设您将社会安全号码存储在表存储中.让我们看两种情况...

For example, say you stored social security numbers in table storage. Let's look at two scenarios...

一个好的分区策略可能是将状态作为分区键.在查询中是否仅传递PartitionKey ='CA'& RowKey ='123456789'Azure表存储知道要转到的分区以及该分区中的确切行.如果您的查询只是:RowKey ='123456789',则Azure Table存储必须扫描所有分区(50个状态)以找到匹配的RowKey.

A good partition strategy might be to have the state as the partition key. In your query if you just pass PartitionKey='CA' & RowKey ='123456789' Azure Table Storage knows the partition to go to and the exact row in that partition. If your query was just: RowKey = '123456789', Azure Table storage has to scan all the partitions (50 states) to find the matching RowKey.

另一种策略可能是使用行键作为社会保险号的一个巨大的单个分区.如果您的查询:RowKey ='123456789',则Azure Table存储可以使用行键上的索引来快速查找值.由于只有一个分区,因此PartitionKey不会成为查询的一部分,这不会减慢它的速度(至少应该不会).

Another strategy might be one huge single partition with the rowkeys as social security numbers. If your query: RowKey = '123456789' then Azure Table storage can use the index on the rowkey to lookup the value pretty quick. Since there is only one partition, the PartitionKey not being part of the query won't slow it down (or at least should not).

还请记住,Azure表存储在内部可以将分区放在不同的驱动器上,以进行优化以提高使用率.因此,为具有很多分区的大型表指定partitionkey是理想的.

Also remember, Azure Table Storage internally can put partitions on different drives for optimizations for heavy usage. So specifying the partitionkey for large tables with lots of partitions is ideal.

这篇关于Azure表按行键查询作为条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆