MySQL : incrementing text id in DB

Posted by BarsMonster on Stack Overflow See other posts from Stack Overflow or by BarsMonster
Published on 2010-12-10T08:53:04Z Indexed on 2011/01/09 2:54 UTC
Read the original article Hit count: 204

Filed under:
|

I need to have text IDs in my application. For example, we have acceptable charset azAZ09, and allowed range of IDs [aaa] - [cZ9]. First generated id would be aaa, then aab, aac, aad e.t.c.

How one can return ID & increment lower bound in transaction-fashion? (provided that there are hundreds of concurrent requests and all should have correct result)

To lower the load I guess it's possible to define say 20 separate ranges, and return id from random range - this should reduce contention, but it's not clear how to do single operation in the first place.

Also, please note that number of IDs in range might exceed 2^32.

Another idea is having ranges of 64-bit integers, and converting integer->char id in software code, where it could be done asyncroniously.

Any ideas?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about autoincrement