Skip to content
pvmehta.com

pvmehta.com

  • Home
  • About Me
  • Toggle search form
  • scripts to take listener.log backup Linux/Unix
  • DBMS_JOB all example Oracle
  • All Hints for Oracle Databases Oracle
  • refre.sql Oracle
  • Nice notes on wait events Oracle
  • This is from Temi Oracle
  • Running some SQL on multiple databases connecting using monitoring userid and password Linux/Unix
  • How to find pinned objects from shared pool. (pinned via dbms_shared_pool.keep) Oracle
  • checking redhat linux version Linux/Unix
  • Implementation of key based authentications Linux/Unix
  • oracle Dba site Oracle
  • Identical Dblink Issue… Oracle
  • Oracle 10g Installation/Applying Patches Tips Oracle
  • Some useful Unix Commands Linux/Unix
  • currwaitobj.sql SQl_ID and SQL statement you can get from currwaitobj.sql Oracle

Insert cause enqueue locks

Posted on 23-Apr-2008 By Admin No Comments on Insert cause enqueue locks

Here is a much simpler version:

——————————-

Create table t1 (c1 number primary);

session1:

insert into t1 values (1);

session2:

insert into t1 values (1);

— would hang

v$lock would reveal session 1 blocking session2 on TX lock

why? because you have a constraint where you are asking Oracle to check uniqueness of data (unique index/unique constraint / primary key).

So Oracle looks as session-2’s data and checks the existing data..it sees session-1’s data uncommitted. Now Oracle doesn’t know if session-1 would commit or rollback. so it has to wait. this is by design.its always been like this.(so session 2 has to enqueue behind session 1 )

if session-1 commits, session would fail since unique key constraint is violated..if session-1 rolls back, session-2 would go through fine.

Its a lock based on “data” . It doesn’t matter what your statement is..(“insert into table values..” or “insert based on select” )..the behavior would be the same.

You don’t see the 2 sessions blocking each other (inserting the same key) when you don’t have any consistency checks (unique index/constraint). Oracle knows it can allow any data..so no locks based on data.

Reference : http://hemantoracledba.blogspot.com/2007/10/inserts-holding-locks-inserts-waiting.html

Oracle, SQL scripts

Post navigation

Previous Post: Reclaim temp tablespace for oracle 8, 8i
Next Post: alter database backup controlfile to trace

Related Posts

  • Benefits and Usage of RMAN with Standby Databases Oracle
  • Oracle Internal Good Websites 1 Oracle
  • Library cahe Latches and internal explaination Oracle
  • Proc Compilation Oracle
  • lck.sql Oracle
  • how to find OS block size Oracle

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • AWS (2)
  • Azure (1)
  • Linux/Unix (149)
  • Oracle (392)
  • PHP/MYSQL/Wordpress (10)
  • Power-BI (0)
  • Python/PySpark (7)
  • RAC (17)
  • rman-dataguard (26)
  • shell (149)
  • SQL scripts (341)
  • Uncategorized (0)
  • Videos (0)

Recent Posts

  • load SPM baseline from cursor cache05-Jun-2025
  • Drop all SPM baselines for SQL handle05-Jun-2025
  • Load SPM baseline from AWR05-Jun-2025
  • Drop specific SQL plan baseline – spm05-Jun-2025
  • findinfo.sql (SQL for getting CPU and Active session info)27-May-2025
  • SQL Tracker by SID sqltrackerbysid.sql22-Apr-2025
  • How to connect to Oracle Database with Wallet with Python.21-Mar-2025
  • JSON/XML Types in Oracle18-Mar-2025
  • CPU Core related projections12-Mar-2025
  • Exadata Basics10-Dec-2024

Archives

  • 2025
  • 2024
  • 2023
  • 2010
  • 2009
  • 2008
  • 2007
  • 2006
  • 2005
  • To see how much time or progress of long transaction Oracle
  • Standby Database Behavior when a Datafile is Resized on the Primary Database Note:123883.1 Oracle
  • UNderstand and eliminate Latch contention. Oracle
  • Very clear article about oracle dataguard Oracle
  • Sort with ASCII order and Numeric Order Linux/Unix
  • TOP-N Sql to find Nth max or Top N rows Oracle
  • Rollback force for distributed transactions Oracle
  • How To Limit The Access To The Database So That Only One User Per Schema Are Connected (One Concurrent User Per Schema) Oracle

Copyright © 2025 pvmehta.com.

Powered by PressBook News WordPress theme