
Ask HN: Primary key based on high-resolution timestamp - prmph
I&#x27;m seeking a primary key for my relational database tables that:
- Can be generated on the client and has a low chance of collisions
- Can support fast (and possibly clustered) indexes well
- Will play well with federation, sharding, and migration scenarios
- Does not leak data about my system internals when used a public object id<p>At first, I thought of using an internal auto-increment integer primary key, and a public client-generated GUID surrogate key. But there are issues with this approach [1]<p>After further thought, I&#x27;m thinking a timestamp (with millisecond resolution) primary key will meet all these requirements well.<p>Are there possible problems with this approach?<p>[1] https:&#x2F;&#x2F;tomharrisonjr.com&#x2F;uuid-or-guid-as-primary-keys-be-careful-7b2aa3dcb439
======
bengunnink
The only problem is it's guaranteed to fail for any non-trivial workload.

~~~
prmph
OK, so what will you recommend to achieve the requirements?

