Results 1 to 5 of 5

Thread: auto increment

  1. #1
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default auto increment

    lets say i have lots of concurrent users clicking away and my dB table uses auto increment for each unique click as a way to create a new row for their input. <br>
    if several people happen to click at the same time could auto increment jam and cause the whole dB to crash?
    Last edited by ggalan; 07-07-2011 at 02:25 AM.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Every time you execute a query, the row is processed then. There is no time to wait. So the only potential time for overlap is during the actual query. This is MUCH smaller than the loading time for the page. Secondly, the processing time within MySQL for auto-increment will be a few milliseconds. That's such a tiny amount that the odds of anyone overlapping are low.
    Now, if that actually happens and somehow they overlap, then I'm not sure what happens. However, I imagine that MySQL is a single process on the server and will put queries in a queue so that two are not executed at the same time. Someone must have thought of this or had that problem and they probably fixed it.


    I would not worry about this. In fact, I don't think there is any way to fix it even if it is a problem.

    Secondly, it's not a horrible disaster if the auto increment index is duplicated. It might be wrong, but it won't crash the database. It will just duplicate the number. That's not awful. The worst that will happen is that things will happen twice based on that ID. If you delete row with ID "4" and there are two of them, then you will delete 2 rows.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    db transactions are queued, so what you're describing won't happen.

  4. The Following 2 Users Say Thank You to traq For This Useful Post:

    djr33 (07-06-2011),ggalan (07-07-2011)

  5. #4
    Join Date
    Jan 2008
    Posts
    441
    Thanks
    67
    Thanked 4 Times in 4 Posts

    Default

    thank you for the response. its hard to test mySql boundaries like this and found it difficult to acquire answers through google searches.
    since i dont have lots of experience with large data sets im trying to understand mySql's potential weakness.

  6. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Thanks for confirming that, traq.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •