Step One ( to speed things up ) run by cron once a night Open database Loop based on previous days load ( about 10k linkcodes ) Make random statecode with no data. End Loop Step Two ( when i generate a page with linkcodes ) Open Database Try to get statecode not in use If avaliable write data to statecode return statecode Else make new statecodes ( about 100 ) write data to statecode return statecode End If