Quantcast
Channel: Fox Infotech
Viewing all articles
Browse latest Browse all 231

Queries Taking Too Much Time Due To Row and Table Locking In Oracle

$
0
0
You are trying to update particular rows in a table in Oracle and the statement taking too much time and after some time you get the error ORA-00054: resource busy and acquire with NOWAIT specified or timeout expired.

After getting this error you identified the problem, to follow Oracle best practices for application development, use the NOWAIT clause and minimize the use of LOCK statements unless the application requires it. When a DML statement runs, the NOWAIT clause returns immediately if there is already a lock on the resource you require for the DML statement.

To avoid the wait during the UPDATE attempt, use the NOWAIT clause in a SELECT before the UPDATE statement in all sessions, as follows:

select * from employees e
where employee_id = 101
for update of salary nowait
;

If another session already has the row locked, you will receive this error message:




Viewing all articles
Browse latest Browse all 231

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>