查询Azure表存储的分区键
我知道天蓝色表存储中的记录是按 PartitionKey 组织并按 RowKey 索引的。 我的应用程序要求我根据时间戳的日期范围查询表存储中的记录。我的表存储中有几千条记录,自然性能非常慢。 原因是 TimeStamp 没有索引。 据我了解,PartitionKey本质上是Ticks中TimeStamp的转换。如果我错了请纠正我。
如果这是真的,我如何查询 PartitionKey 而不是 TimeStamp 字段的表存储并提高性能。
I am aware that records in azure table storage is organized by PartitionKey and indexed by RowKey.
My application requires that I query the records in table storage based on the date range of the TimeStamp. I have couple of thousands records in the table storage and naturally the performance is extremely slow.
The reason being, TimeStamp is not indexed.
As I understand, PartitionKey is essentially a conversion of the TimeStamp in Ticks. Correct me if I am wrong.
If this is true, how can I query the table storage on PartitionKey instead of TimeStamp field and improve the performance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以确定自己的分区键,这样它就可以是您想要的。
You determine your own partition key so it can be what you want.
时间戳记录实际上是供azure内部使用的,您不想将其用于业务逻辑。
如果您当前有一个任意主键,那么您可以将主键设置为您自己处理的日期时间(使用行键来确保唯一性)。如果在运行更新时需要根据实际时间戳进行更新,那么您可以使用删除并重新插入模式进行更新。
如果当前主键和行键很重要,则创建一个查找表。即一个表仅将时间戳作为主键,并将另一个表的主键作为行键。然后你可以使用这个表从主表中找到你需要的记录。
The timestamp record is really for azure's internal use, you don't want to use it for your business logic.
IF you currently have an arbitrary primary key then you could make the primary key be a datetime of your own handling (using the rowkey to ensure uniqueness). If it needs to be updated when you run an update, as per the actual timestamp, then you could update using a delete and re-insert pattern.
If the current primary and row keys are important then create a lookup table. I.e. a table that just has the timestamp as the primary key and the primary key of your other table as it's rowkey. Then you can use this table to find the records you need from the main table.