I have a number of records in a table and need to find a way to assign some unique codes that
- Should be unique;
- Should consist of lowercase letters only (no digits) so it's easy for people to mention record codes over telephone using a phonetic alphabet eg - "Hi, this is John, my code is: alpha zulu whisky foxtrot";
- Should be as short as possible.
Records have an expiration date of about 2 weeks, then they are deleted.
New records are created constantly at a rate of several thousand per day. The table gets a couple thousand selects per second.
Ideally this should happen in SQL only so I can add it to a "before insert" trigger and not hit the database with selects to check for uniqueness of application-side generated codes, which is what I'm playing with now and can come with significant overhead, I won't even post the code here.