How likely is it to repeat a rowkey row, which depends on the date and time in Azure

Is it possible to repeat the RowKey in an Azure table, which is structured as follows?

string.Format("{0:d19}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks) 

The same can be set:

Will my webrole create two entries before we get a new value for Ticks?

I want to return objects in reverse chronological order. It is expected that new entities will not be constantly added to this table, but hopefully there will be many insert transactions.

Decision

OK, this is the solution I came across thanks to Mark Simen:

string.Format ("{0: d19} + {1}", DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks, Guid.NewGuid (). ToString ("N"))

Using Guid, I know for sure that rowkey will not be repeated.

+4
source share
1 answer

The probability of getting more than one identical keyword is 1 , since the number of simultaneous write operations is approaching infinity :)

Seriously, Tick is 100 nanoseconds. Modern processors work at a speed where you will have hundreds of processor cycles in one tick, so getting identical Ticks will be .

In fact, yesterday I was talking with one of my clients. He had this exact problem, and she had to crack it to ensure uniqueness.

Consider introducing a truly unique component (such as a GUID) as part of a (sortable) composite.

+4
source

Source: https://habr.com/ru/post/1336451/


All Articles