Afficher un message
Vieux 26/03/2008, 00h30   #6
Erland Sommarskog
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Selecting alphanumeric combinations that do not exist already in table?????

rbr (ryankbrown@gmail.com) writes:
> I have considered the speed and space issues. Unfortunately, there are
> over 14 million usernames currently in use and another 10 million
> reserved for currently inactive customers. The process of generating
> names and checking if they are taken is getting tougher. The idea my
> boss had was to create a table (once) of unused usernames and randomly
> pick one from the list each time. If this is not feasible (you all
> make very good points) I would be more than happy to tell him so.
> However, I figured it would be worth investigating before saying it
> was impossible.


Impossible it isn't. But it's definitely a waste of disk space.

Even if you have 24 million codes already taken, that's only a little
more than 1% of the total space consumed, so I think that if every time
you need a code, generate a random code, check if it is in use this
should be efficient enough. For about each 10000 customer you will have
to generate three codes before you have an unused code.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
  Réponse avec citation
 
Page generated in 0,04875 seconds with 9 queries