Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7879207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:51:05+00:00 2026-06-03T03:51:05+00:00

What happens when more than one user inserts data in Database (MySQL, Postgres) at

  • 0

What happens when more than one user inserts data in Database (MySQL, Postgres) at exactly same time? How does it prioritize which record to be inserted first and which one later. If the answer is specific to application of program, I am asking in reference to web-applications.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:51:07+00:00Added an answer on June 3, 2026 at 3:51 am

    It’s never exactly the same time. One will happen before the other.
    Which one will, unless you implement your own prioritisation mechanism, is indeterminate, and you should never rely on it.

    As to what will happen, well that depends.

    For two inserts to the same table, if data integrity is dependant on what order they are executed in your database design has a horrendous flaw.

    For collisions (two updates to the same record for instance). There are two implementations.

    Pessimistic locking. Assume there will be a significant number of updates to teh same data, so issue a lock around it. If The lock exists fail the update (e.g. second one if first hasn’t finished) with some suitable message.

    Optimistic locking. Assume collisions will rarely happen. Usual way of doing this is to add a timestamp field to the record which changes every update. So when you read the data you get the timestamp, and when you write the data you only do it, if the timestamp you have matches the one that’s there now, and update said timestamp as part of it. If it does not match you do the “Someone else has changed this data message”.

    There is a compromise position, where you try and merge two updates. (for instance you change name and I change address). You need to really think about that though, it’s messy, and get very complicated very quickly, and getting it wrong run’s a real risk of messing up the data.

    People with far larger IQs than mine spend a lot of time on this stuff, personally I like to keep it like me, simple…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While unistalling the application normally if more than one user is logged in the
Is it possible to use Django's user authentication features with more than one profile?
I seem to often find myself wanting to store data of more than one
What happens on a Windows box once you add more drives than can fit
Is there a way to select more than one files to upload when a
What happens if a long running page is closed by the user before he
We have a complex Stored Procedure which first does INSERTS and then does UPDATES
I'm debugging an old Infragistic grid. One of the javascript functions executes more times
It happens like this: http://img815.imageshack.us/img815/2608/senzatitolo1c.png With this HTML: <div style=border:1px solid> <img style=float:left> text
What happens (in terms of CLR) when the code on a classic ASP page

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.