The Scenario
Update: It was brought to my attention that ordering by created_at will actually compare a millisecond float that’s of sufficient resolution (by far). However, while I feel a bit dumb now, my question still stands. My scenario is just irrelevant, so I removed it.
The Question
I know that the database knows precisely the order of creation by tracking a row’s ID.
Are there any pitfalls in relying on latest ID to determine order?
A better solution is to replace the latest_post_at with something more precise than a second.
Time.now.to_finstead of.to_iwill give you sub-second precision (millisecond I think, the docs aren’t clear). Should two posts happen to have the same millisecond timestamp you could use the id as a tie-breaker.