Whizzil
Whizzil

Reputation: 1364

Run UPDATE query while the INSERTs are running

I have a DB table which size is around 100,000 rows. I Need to run an UPDATE query on that table (affecting every row) which runs for approximately 25 minutes. During this 25 minutes, there will be approximately 300 INSERTs to the same table.

I'm wondering whether those INSERTs will run? Will they be blocked for the time the UPDATE is running, and then executed, or will they just never be executed?

I'm using Postgres database.

Upvotes: 1

Views: 60

Answers (2)

jjanes
jjanes

Reputation: 44287

If the update starts before the insert commits, then 100,000 existing records will be updated, the 300 new ones will not be. They will not block each other, unless there is something else going on like attempts to violate a constraint or elaborate triggers.

Upvotes: 1

user330315
user330315

Reputation:

Yes, those inserts will run.

An UPDATE, even when changing all rows, does not block the INSERTs

Upvotes: 3

Related Questions