I am trying to generate a unique number by using a recursive workflow.
Basically, I’ll be generating a random 15 number value and then checking it against the user table to see if the number exists. If it exists, then run the workflow again till it finds a unique number.
If my users table has around 20-25 thousand records, how do I calculate how many WU are required to perform this recursive operation?
Well, a 15 digit number (using the digits 0-9) has exactly 1,000,000,000,000,000 (one quadrillion) possible combinations.
As you already have 25k records, assuming each has a unique 15 digit number, the odds of a single newly generated random 15 digit number being a duplicate of an existing one are 25,000 in 1,000,000,000,000,000
Which is basically 0
(for comparison, you’re about 13,000 times more likely to win the US Powerball lottery jackpot with a single ticket, than you are to get a duplicate in your database with a single newly generated number).
So in terms of the WU cost of running this recursive operation… there won’t be any.
But… the question is why are you doing this? Bubble already generates a unique ID for all things…
I was facing some issues when using unique ID generated by bubble in Zapier, So I was exploring alternatives.
That’s probably a live/test database separation issue. The unique IDs generated by Bubble are always unique and are ideal to use if you just need a random ID and don’t need to to meet any other length/format requirements.
This topic was automatically closed after 70 days. New replies are no longer allowed.