Re: Selecting alphanumeric combinations that do not exist already in table?????
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Tue, 25 Mar 2008 22:30:37 +0000 (UTC)
rbr (ryankbrown@xxxxxxxxx) 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@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- References:
- Prev by Date: Re: Is it possible to cascade table and field name changes to views
- Next by Date: Re: Triggers and Flag bit
- Previous by thread: Re: Selecting alphanumeric combinations that do not exist already in table?????
- Next by thread: Re: Selecting alphanumeric combinations that do not exist already in table?????
- Index(es):
Relevant Pages
|