Call now: 252-767-6166  
Oracle Training Oracle Support Development Oracle Apps

 
 Home
 E-mail Us
 Oracle Articles
New Oracle Articles


 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog


 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Analysis
 Design
 Implementation
 Oracle Support


 SQL Tuning
 Security

 Oracle UNIX
 Oracle Linux
 Monitoring
 Remote s
upport
 Remote plans
 Remote
services
 Application Server

 Applications
 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S
upport  
 Development  

 Implementation


 Consulting Staff
 Consulting Prices
 Help Wanted!

 


 Oracle Posters
 Oracle Books

 Oracle Scripts
 Ion
 Excel-DB  

Don Burleson Blog 


 

 

 


 

 

 
 

select for update skip locked tips

Oracle Database Tips by Donald BurlesonApril 7, 2015

Question: What does the 11g "skip locked" do in a select for update statement?

Answer: The "select for update" statement has always been problematic for large updates because it the default is to wait for locks and using "select for update" other tasks can abort waiting on access with the ORA-300036 error:

ORA-30006: resource busy; acquire with WAIT timeout expired

In other cases using "select for update" with the "nowait" clause you your own update may abort with the ORA-00054 error:

ORA-00054 resource busy and NOWAIT specified

Even worse, if a select for update task aborts, a zombie process may hold the row locks long term, requiring DBA intervention.

Before the 11g "skip locked" directive, long-running update transactions will either re-select a row before updating it to ensure that it has not changed since the last read, or add a date-time stamp column to the table to see if it had been updated since the transaction began.

Starting in 11g, using select for update with the skip locked directive will tell the update to skip-over any rows that are already locked. This is useful in high DML environments because it removes the locking and concurrency issues, but data cohesion will become an issue.

For example, assume that a select for update requests 1,000 rows and 200 are already locked by other transactions that are updating the credit column:

select
   cust_status
from
   customer
where
   credit='GOOD'
for update skipped locked;

As we see, those 200 rows that were being updated may have experienced a change to credit='BAD', making our update invalid, and causing logical data corruption.

Note: In some cases you may need to increase the value of a table's initrans values to allow for more locking buckets:

alter table customer move initrans 200;

In sum, the select for update skipped locked is useful in high concurrency environments to prevent locking errors, but you run the risk of logical corruption where a changed value is dependent upon another column value within the row. In general, the re-read strategy is better, where you re-read each row before update in to ensure that it did not change since the initial read.

 


 

 

Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


                    









Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


 

Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational

 

 

��  
 
 
Oracle Training at Sea
 
 
 
 
oracle dba poster
 

 
Follow us on Twitter 
 
Oracle performance tuning software 
 
Oracle Linux poster