在 Azure Table 存储中使用时间戳作为 RowKey 是否合理?

Is the use of Timestamp as a RowKey in Azure Table Storage justifiable?

对于我的模式,我可以选择一个好的分区键,但不幸的是,我在分区内没有任何唯一的东西。所以我决定按以下方式使用 DateTime 属性 作为 RowKey:

RowKey = DateTime.UtcNow.ToString("yyyyMMddHHmmssfffffff");

这种使用是否合理?

你可以把DateTime当成RowKey,这样的设计是合理的。您还可以考虑使用反向刻度 string.Format("{0:D19}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks),它按相反的日期和时间顺序排序,因此您可以轻松检索 PartitionKey[ 中的最新 n 实体=19=].

要查看更多详细信息,您可以在 Azure Storage Table Design Guide 中查看 "Log tail pattern"。