Solved

Are race conditions an issue in mySQL INSERTs?

Posted on 2011-03-02
2
561 Views
Last Modified: 2012-05-11
Hello.  I am new to the concept of race conditions, and most of my tables have numeric primary keys set to auto-increment.  Is this a potential problem?  As in, is it possible that 2 INSERT statements could fire simultaneously on a table and leave me with 2 rows with matching primary keys?
0
Comment
Question by:chaseivey
2 Comments
 
LVL 38

Accepted Solution

by:
Aaron Tomosky earned 65 total points
ID: 35024275
Nope. SQL is made for that stuff.
0
 
LVL 4

Assisted Solution

by:gizmola
gizmola earned 60 total points
ID: 35025676
A primary key is by definition unique, so there's no possibility of that happening.  Additionally AUTO_INCREMENT is inherently built around a table lock that serializes the allocation of new id's to insert statements.

0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question