Query execution on azure storage is very slow

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 09:31:37

问题


I am trying to query against timestamp column on a azure table storage. I have a where condition which checks if input value is greater than timestamp value. azure Timestamp column is not a partition key or row key. I came to know querying against column which is not partition or row key will decrease performance of the query execution. My application is very slow when there are more and more records. I tried to move time stamps data to partition key data but partition key is not accepting time stamp value like "4/13/2016 5:20:03 AM +00:00". What would be the best option to increase query performance.


回答1:


As you have mentioned already, if a query doesn't include PartitionKey and/or RowKey the queries will be slow because Table service is doing full table scan. Recommendation would be to use the date/time value as PartitionKey value.

I tried to move time stamps data to partition key data but partition key is not accepting time stamp value like "4/13/2016 5:20:03 AM +00:00"

This is because the value contains characters that are not allowed (https://msdn.microsoft.com/en-us/library/azure/dd179338.aspx --> see Characters Disallowed in Key Fields section).

There're actually a number of things you could do to solve this problem:

  • You can format your date/time value in YYYY-MM-DDThh:mm:ss format.
  • You can convert the date/time value to ticks and prepend some zeros in front and save that for PartitionKey. Something like:

    PartitionKey Value = YourDateTimeValue.Ticks.ToString("d19");

If you want the most recent entries to come on the top, you could do something like:

PartitionKey Value = (DateTime.MaxValue.Ticks - YourDateTimeValue.Ticks).ToString("d19");

You may also find this useful: https://azure.microsoft.com/en-in/documentation/articles/storage-table-design-guide/.



来源:https://stackoverflow.com/questions/36589493/query-execution-on-azure-storage-is-very-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!