I can set the primary key as a timestamp accurate to seconds. But it works as intended only when new rows are inserted a minimum of 1 second apart. I can increase the resolution to microseconds, but I wonder if it’s overkill and slow stuff down.
I want timestamps since they are easy to sort on time but I don’t care about prescription greater than a second.
What is a good way to generate them?
It all depends on what queries you expect to process.
You can actually use both
TIMESTAMPand some surrogate primary key; the latter would be auto_incremented, as usual, and the former may be indexed over as well for some sorting queries:… or you can drop the surrogate key altogether and go without
PRIMARY KEY-w With a singleINDEXoverTIMESTAMPcolumn (remember,INDEX!=UNIQUE).I would use the first approach, though; it’s more flexible and extensible.