Reputation:
First of all, my question has nothing to do with this one.
When querying a MySQL database for insertion: suppose several users try to insert rows on the same time on the same database table: does MySQL RDBMS lock the insertion process when one insertion is in progress ? Or does it allow multiple insertions at the same time ?
I ask this question because I am naming images inserted by users using the timestamp. However, timestamp uses seconds. So if 50 users insert images in the same seconds: how MySQL will treat them ? Will I have 50 images with the same name ?
Upvotes: 5
Views: 1923
Reputation: 7590
Yes, you will (almost certainly) get multiple images with the same timestamp.
You can use AUTO_INCREMENT, UUID(), or another approach to generate unique values, but timestamps (even microsecond precision ones) are not unique.
Upvotes: 1