Hello,

Artyom wrote:

> As I mentioned before, UUIDs do not solve problem of "last_insert_id()"
> when you want to keep your IDs low, in such cases, auto-increment/sequence
> are much more reliable.

Another possible solution to this problem is:

1. use some domain-level data that actually identifies the new record 
(user name, login, address, etc.)
2. hash it (md5, sha1)
3. take the first 4 or 8 bytes of the hash and use it as a key for the 
new record.

The advantage of this solution is that such IDs are generated in a 
widely scattered way (seemingly randomized within the target range), 
which is *very healthy* for tree-like indexes for the reason that 
indexes created this way are naturally balanced.

I'm not sure what do you mean by keeping IDs low, but I assume that you 
simply do not want to expose extremely long sequences like UUIDs.
I think that hash prefixes fit your requirements - they do pretty well 
as commit identifiers in Git, for example.

For an example of something that gives similar results, see the form of 
  YouTube video links. The stuff that is appended after the domain name 
does not look like a last_insert_id to me, it is almost certainly a hash 
of some sort.

Regards,

-- 
Maciej Sobczak * www.msobczak.com * www.inspirel.com

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to