We are having a code where we are updating the rows in a column based on a simple single where condition. Now, the code is in production but it is found that it locks the whole table sometimes. Please suggest how to prevent the table from being locked.
We are just updating a single row but yes there are multiple users of the application.
Are you sure the update is locking it? Have you used some database tools to identify the offending transaction/statement? There could be some other, overlooked process that is locking the table (eg. deleting a row from a parent table might lock the child table if it doesn't have its foreign key indexed).
Assuming it is the update operation, it might be caused by lock escalation. The details of locking are database dependent. Some databases don't ever escalate locks, while others do, under different conditions. I'd suggest to consult your database documentation to find out why, when and how a lock escalation can occur.
Seriously? That's what you're going with? I prefer this tiny ad:
a bit of art, as a gift, that will fit in a stocking