Can AUTO_INCREMENT id column be used in place of DATETIME column just for ordering in SQL?

Viewed 30

In an auto-incrementing column, the newer items have higher ids. Can this property be used for sorting based on datetime? Can it potentially remove indexing in datetime column?

1 Answers

No. (Unless your application is single-threaded.) Any inserts sent simultaneously over a network have no guaranteed order so the IDs generated by the auto-increment might not be monotonic with respect to any DATETIME values you might provide.

Related